Thanks to George I slowly got to the answer. The root of the problem lies in that I installed my Python 3.5.2 version from a source rather than from the Ubuntu aptitude package manager.
Basically, if Python is installed from a source, then, to look for 3rd party packages, it uses /usr/local/lib/python3.5/site-packages
, but if it was installed using apt
, then Python looks in /usr/local/lib/python3.5/dist-packages
. This is to make sure that the several Python versions don't get tangled up. Here is another question that explains: what is the difference between dist-packages and site-packages?.
Solution:
My Python3 installation was looking into site-packages and ignoring dist-packages, so I added a path file to make it look inside dist-packages as well.
cd /usr/local/lib/python3.5/site-packages
sudo vim dist-packages.pth
(Press i to go into insert mode inside Vim)
../dist-packages
:x (and Press Enter/Return)
Now when Python looks inside /site-packages
, it finds dist-packages.pth
which makes it go into /dist-packages
.
Other Solution:
Someone else had a problem exactly the reverse of mine, where their Python installation only looked inside /dist-packages
, so they used the exact same method as above except instead of making a dist-packages.pth
file (containing ../dist-packages
) inside /site-packages
, they made a site-packages.pth
file (containing ../site-packages
inside /dist-packages
.
Check if it worked:
The easy way to check if this worked is to go into your Python interpreter and print sys.path. It should now contain both package paths:
charliebrown@playground:/usr/local/lib/python3.5/site-packages$ python3
Python 3.5.2 (default, Nov 19 2016, 02:36:25)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; print(sys.path)
['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages']
I hope this helps someone one day...
sudo pip3 install pyqt5
and test againsudo -H pip3 install pyqt5
this time lets see what happens. Quite strange as I have successfully installed it on my system, also dosudo apt update && sudo apt dist-upgrade
before thepips
commandpython 3 import site; site.getsitepackages()
that it only finds /usr/local/lib/python3.5/site-packages, and it doesn't list the /usr/local/lib/python3.5/dist-packages that the actual modules are installed in. Do you think that might be my problem?