As I am using Xubuntu I thought perhaps this was a better forum than Stackexchange for some questions relating to pip and Python
Today I have encountered troubles with pip and Python.
For some reason I can install packages with pip install
but the packages are not picked up by Python. If I start any session
Python2.7 Python3.4.3 or Python3.5 and do an import of the installed package it returns the import error
No module named 'xxx'
It could be one or several environmental variables that is wrong in my setup. But I do not know what the correct settings would be for it to work.
locate Python.h
gives
/usr/include/python3.4m/Python.h
/usr/local/include/python3.4m/Python.h
but there are more directories in /usr/include
python2.7
python3.4
python3.4m
python3.5
python3.5m
What more information do you need to to help me locate my errors? Preferably I would like to be able to pip install to each Python version separately, as described here PIP configuration instructions
As I have been fiddling in the system during the morning I can no longer use the instructions mentioned above. I am lost in the file structure.
py@test:/etc/python$ python 3.5 -m pip install urllib3
python: can't open file '3.5': [Errno 2] No such file or directory
Even more interesting is that when I tried to fix the problems and reinstall pip
sudo python3.5 get-pip.py
It was updated a couple of generations
pip-7.1.2-py2.py3-none-any.whl (1.1MB) 100% |████████████████████████████████| 1.1MB 73kB/s Installing collected packages: pip Found existing installation: pip 1.5.6 Uninstalling pip-1.5.6:
Successfully uninstalled pip-1.5.6 Successfully installed pip-7.1.2
For some reason the system has not protested about the aged pip-installation. But it has protested in the Windows environment.
Earlier I have been able to install packages with pip and it have been usable in Python3.4 with import
but something has happened lately which has corrupted the connections between pip and Python.
EDIT:
If I do
python2.7 -m pip install urllib3
/usr/bin/python2.7: cannot import name IncompleteRead; 'pip' is a package and cannot be directly executed
Answering @dragon2fly questions:
In Python 3.5.0+
print(sys.path)
['', '/home/ike', '/usr/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/ike/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
In Python 3.4.3
['', '/home/ike', '/usr/bin', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/home/ike/.local/lib/python3.4/site-packages', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
When I use the different pip versions I get:
pip show cv2
Metadata-Version: 2.0 Name: cv2 Version: 1.0 Summary: My Blog Distribution Utilities Home-page: http://blog.liuts.com Author: xuyouwen Author-email: 871140705@qq.com License: UNKNOWN Location: /usr/local/lib/python3.5/dist-packages Requires:
pip3 show cv2
--- Metadata-Version: 2.0 Name: cv2 Version: 1.0 Summary: My Blog Distribution Utilities Home-page: http://blog.liuts.com Author: xuyouwen Author-email: 871140705@qq.com License: UNKNOWN Location: /usr/local/lib/python3.5/dist-packages Requires:
I have narrowed down one of the installation errors. I have cv2 installed but cannot import it.
python3.5 -m pip install cv2
Requirement already satisfied (use --upgrade to upgrade): cv2 in /usr/local/lib/python3.5/dist-packages
However if I import it in Python 3.5.0+
import cv2
Traceback (most recent call last):
File "", > line 1, in import cv2
ImportError: No module named 'cv2'
I have four pip
pip pip2 pip3 and pip3.5
import sys; print sys.path
and$pip show xxx
wherexxx
is your installed package through pip?import sys; print(sys.path)
in a python interactive season or put it into asome_name.py
file and do$python path/to/some_name.py
.pip show cv2
should be run in shell.sudo apt-get install python-opencv
. Currently this way is good for python2, if you want to use opencv with python3+, you have to compile it from source and use the source of 3.0+ version not 2.4.xx