Reputation: 4367
I had an old version for Python. Then I uninstalled the old version, and install a new one - 2.7.9.
I set the 2.7.9 as my global version via pyenv
but all my modules not being detected. They were installed before the upgrading. Now I uninstalled them and reinstall but still not working...
~/Projects/development$ python
Python 2.7.9 (default, Mar 3 2016, 16:42:45)
[GCC 4.6.3] on linux2
>>> from github import Github
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named github
They already reinstalled after the python upgrading! Trying to install them again, gives Requirement already satisfied error.
~/Projects/development$ pip install PyGithub
Requirement already satisfied (use --upgrade to upgrade): PyGithub in /usr/local/lib/python2.7/dist-packages
Cleaning up...
What can I do?
~/Projects/development$ pyenv versions
system
* 2.7.9 (set by /home/user/.pyenv/version)
~/Projects/development$ python
Python 2.7.9 (default, Mar 3 2016, 16:42:45)
[GCC 4.6.3] on linux2
>>> sys.executable
'/usr/local/bin/python'
>>> sys.exec_prefix
'/usr/local'
>>> print '\n'.join(sys.path)
/usr/local/lib/python27.zip
/usr/local/lib/python2.7
/usr/local/lib/python2.7/plat-linux2
/usr/local/lib/python2.7/lib-tk
/usr/local/lib/python2.7/lib-old
/usr/local/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/site-packages
which pip
gives /usr/bin/pip
.
Upvotes: 5
Views: 6584
Reputation: 4367
I found the problem.
dist-packages vs. site-packages.
Using prev Python version, and also after upgrading, my packges were installed by pip to /usr/local/lib/python2.7/dist-packages
, whereas the new Python I installed expects packages to be installed to /usr/local/lib/python2.7/site-packages
(When manually installing Python from source, it uses the site-packages directory. See more here). I can temporary copy the modules, or just manipulate the PYTHONPATH
environment variable to point to dist-packages in order to gain access to the installed packaged with the newly installed version of Python.
From here.
Upvotes: 3