I was trying to import setuptools in Python3.4 as following,
>>> from setuptools import setup
But I got the ImportError: No module named 'setuptools'.
My current version of Python3.4 is Python 3.4.0b1 (default, Nov 29 2013, 16:37:17), and it is installed using MacPorts.
So there is no setuptools module contained in Python 3.4 Standard Library, right? and I need to install setuptools module through pip?
Update:
setuptools is not in the standard library. But I cannot install it through pip because pip need setuptools installed first. MacPorts contains py34-setuptools #2.0.2 port and I can install setuptools through it.
setuptools has never been a part of the standard lib. You'll always to download it separately.
For 3.4, download setuptools - (This is the compressed download link!), extract it and install it via:
python setup.py install
You'll have to install it yourself. If you've got a completely empty environment in a new python installation, have a look at the official install instructions.
It works for me, but I'm using 3.4b2 on a Linux Mint system:
$ /usr/local/cpython-3.4/bin/python
Python 3.4.0b2 (default, Jan 5 2014, 13:53:24)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from setuptools import setup
>>>
Related
I am trying to download a library called Albow. I tried using pip to install it, but it didn't work, so I went to the Albow website and it linked to a .zip file. Basically what I want to do is to make it so that when I type:
import albow
Python recognizes it.
I'm using Python 3.5.3, on a Debian Linux VM. My PC's OS is using ChromeOS.
If I missed something that I should explain, I will edit the question.
The Albow website you linked to (or this other one from the Pygame projects) only supports Python 2. It's not available in PyPi so pip install would not work.
Since you tagged this python3.5, I assume you want Python 3 support.
There is a ported version available from PyPi: https://pypi.org/project/python3-albow/.
This project is a port of Gregory Ewing's Albow project (https://www.pygame.org/project/338/4687) that is only compatible with Python 2 and is unsupported since 2014.
You should be able to install it using standard pip install
$ python3.5 -m pip install --user python3-albow
...
Installing collected packages: pygame, python3-albow
Successfully installed pygame-1.9.6 python3-albow-2.7.8
$ python3.5
Python 3.5.9 (default, Nov 24 2019, 01:35:13)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import albow
>>> albow.__path__
['/home/gino/.local/lib/python3.5/site-packages/albow']
>>>
Or, preferably, setup a virtual environment and install it there.
I have such a problem
(face_det) user#pc:~$ python3
Python 3.5.3 (default, Apr 22 2017, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2
I don't have it on python2:
(face_det) user#pc:~$ python2
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import cv2
>>>
In spite of the fact, that I have opencv (I've also tryed to remove it and install then):
(face_det) user#pc:~$ pip3 install opencv
Requirement already satisfied: opencv in ./.virtualenvs/face_det/lib/python3.5/site-packages
(face_det) user#pc:~$ conda install opencv
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/pc/anaconda3:
#
opencv 3.2.0 np112py27_0 conda-forge
Try
pip3 install opencv-python
to get the cv2. I'm not sure when opencv-python became available. I'd been building opencv by hand, but when I looked a few weeks ago, there it was. I'm using cv2 with Python3 in a VM that's running ubuntu/trusty64.
Try
sudo python3.5 -m pip install opencv-python
It worked for me
On Windows you can try this:
python3 -m pip install opencv-python
Your conda openCV is installed for use by your home python2.7. Your opencv installed via pip3 is for use in your face_det virtual environment. It doesn't look like you're in that virtual environment when you opened python3 in the first code block. Try
source activate face_det
python3
import cv2
I think you're on Linux judging by pc:~$
Try installing from the following link:
http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/linux_install/linux_install.html
It worked for me, hope the same for you!
I had a similar problem and the same error. In my case, I was using PyCharm. The problem was that the project's interpreter was pointing to a different installation of Python.
In my system, I had four versions of python (eg. python3 installed in a python36 folder, another python in an anaconda3 folder and others). In my PyCharm project, when I examined my settings (under File->Settings->Project:xxxx ->Project interpreter), I found that they were pointing to the interpreter in the anaconda3 folder.
However, my default pip installed the opencv-python module under the python36 folder. Therefore, I just had to change the project interpreter to point to the python installed in python36 folder and it worked.
If you would like to keep using Anaconda3 then you have to browse to the anaconda3 folder and run pip install opencv-python in that folder.
Im fairly new to programming and Ubuntu. Yesterday I finally managed to create a dual-boot system, so now I'm running Ubuntu 12.04 LTS.
For a school project, I need to work in Python3 with a module called SPARQLWrapper (https://pypi.python.org/pypi/SPARQLWrapper).
On my freshly installed Ubuntu, I've installed the latest version of Python. When I type "python3" in my terminal, python 3.2.3 starts so thats good.
I installed easy_install (sudo apt-get install python-setuptools), and downloaded and installed the SPARQLWrapper egg file (sudo easy_install SPARQLWrapper-1.5.2-py3.2).
If I run python2 and use "import SPARQLWrapper", it just works. But if I try the same in python3 it gives me the following error:
x#ubuntu:~$ python3
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import SPARQLWrapper
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named SPARQLWrapper
So my problem is that python3 isn't able to acces the same modules as my python2. How do I fix this?
Thanks!
To install packages for Python3, you need python3's setuptools.
Following are the steps to be followed to install python3's setuptools and SPARQLWrapper
sudo apt-get install python3-setuptools
sudo easy_install3 pip
pip -V This should show the pip corresponding to your python3 installation.
sudo pip install SPARQLWrapper
After doing the above mentioned steps, I get this
~$ python3
Python 3.3.1 (default, Apr 17 2013, 22:30:32)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import SPARQLWrapper
>>> exit()
~$
Each Python installation has its own modules directory. In addition, Python 3 is not backwards compatible and won't generally run Python 2 code. You'll need to find a Python 3 version of the module you need and install it for Python 3.
I am working on a RHEL system. I have two versions of Python installed on my system: Python 2.4 and Python 2.7, but I have created an alias in the .bashrc file so that the python command prompts Python 2.7 instead of Python 2.4.
I need to install zlib in my system. I tried to install it using the yum command:
yum install zlib
yum install zlib-devel
both worked fine, but when I type "python", I still cannot see zlib installed:
[root#mymachine]# python
Python 2.7 (r27:82500, Jan 18 2012, 17:03:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zlib
But if I import zlib from Python 2.4, it works! Why? I need zlib to be installed using Python 2.7. How can I do that? Thank you in advance!
Generally you will only find RPMs for the default Python version in the yum repository, however that shouldn't really be applicable here since zlib should be installed by default in your Python 2.7 installation.
Check sys.path using import sys; print sys.path and make sure that you have the lib directories for your Python 2.7 installation, it is possible that whatever you are doing in .bashrc is causing you to pick up the Python 2.4 environment.
Here is the location of my zlib module, which may be useful in trying to track down the location of yours so you can make sure it is on sys.path.
>>> import zlib
>>> zlib
<module 'zlib' from '/usr/local/lib/python2.7/lib-dynload/zlib.so'>
If you cannot find it then you should reinstall Python 2.7.
The zlib and zlib-devel packages are the C shared and development libraries, respectively; the zlib you are importing in Python 2.4 is the one that shipped in the python-libs package:
$ rpm -qf /usr/lib64/python2.4/lib-dynload/zlibmodule.so
python-libs-2.4.3-46.el5
I don't know where you got your Python 2.7 from, but zlib is part of the standard library--it should have been built with Python. You will need to acquire a zlib module that was built against Python 2.7.
I would like to install a module but pip is not installing it in the right directory which I assume should be /usr/local/lib/python2.7/site-packages/. After all, I just installed Python 2.7.2 today. Originally I had 2.6.5 and had installed modules successfully there. So I think something is wrong with my Python path.
How to have all my module installations go to the proper python2.7 directory?
s3z#s3z-laptop:~$ pip install requests
Requirement already satisfied: requests in /usr/local/lib/python2.6/dist-packages/requests-0.6.1-py2.6.egg
Installing collected packages: requests
Successfully installed requests
s3z#s3z-laptop:~$ python
Python 2.7.2 (default, Oct 1 2011, 14:26:08)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
>>> ^Z
[3]+ Stopped python
Also here is what my Python directories look like now http://pastie.org/2623543
After you installed Python 2.7, did you install the Python 2.7 version of easy_install and PIP? The existing installations are configured to use Python 2.6 by default which may be causing your issue.
You are probably using pip linked to python2.6, instead of 2.7. If you have installed pip properly with python2.7, you can do:
pip-2.7 install requests
If not, try installing this way:
curl -O http://python-distribute.org/distribute_setup.py
[sudo] python2.7 distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
[sudo] python2.7 get-pip.py