I have Python version 3.5.2 and I have pip3, so I did

sudo pip3 install pyqt5

That got installed in /usr/local/lib/python3.5/dist-packages

However when I enter my python 3 interpreter and type

import PyQt5

it gives me an error that it can't find the module named PyQt5.

So I tried adding the /usr/local/lib/python3.5/dist-packages path to PYTHONPATH by doing

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages

but that didn't fix anything. How do I make Python 3.5.2 detect PyQt5?

  • do sudo pip3 install pyqt5 and test again Dec 6, 2016 at 5:11
  • @George ah sorry, I forgot to mention that I did try sudo from the very start. I edited my question to portray that. All it says is "pyqt5 in /usr/local/lib/python3.5/dist-packages"
    – Shadowfax
    Dec 6, 2016 at 18:46
  • try running sudo -H pip3 install pyqt5 this time lets see what happens. Quite strange as I have successfully installed it on my system, also do sudo apt update && sudo apt dist-upgrade before the pips command Dec 6, 2016 at 19:12
  • Oh, I just noticed after doing python 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?
    – Shadowfax
    Dec 6, 2016 at 19:15
  • No shakes just redo! Dec 6, 2016 at 19:17

1 Answer 1


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?.


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)
: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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.