I am using Redhat Linux, and the default Python version is 2.6, so I installed Python 2.7.4 on /user/local/bin folder and modified the shell profile, so when I do:
$which python
/usr/local/bin/python
which is good.
Since I don't have super user permission of the box so I tried to install the Python libraries to a folder that I have write permission. So this is the structure of my libraries:
I created a folder called
/share/python
And under that folder, I created another folder called library where I put all the python library source folders. Say I want to install the pyes (Python Elastic Search) package. I first downloaded the source_folder, tar unzip and cd into the folder. Then I did
python setup.py install --prefix=/share/python
Then the installation finished successfully(I have done this before) and created two library folders under
/share/python/lib/python2.7/site-packages/
And they are
urllib3-1.6-py2.7.egg
pyes-0.20.1-py2.7.egg
And when I open Python. Print out sys.path to double check my customized library path has been included. This is what it said:
>>import sys
>>print sys.path
['','/usr/local/lib/python2.7/site-packages/...'..., '/share/python/lib/python2.7/site-packages']
And I am pretty sure python knows where to find the pyes and urllib3(installed as dependency). however, I still cannot load the library and the error looks like this:
>>> from pyes import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyes
>>> import urllib3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named urllib3
Any idea why would this happen?
Updated: You need to add those new egg folders into your path and it will work: Still not quite sure why python setup.py install created two eggs folder but don't add them to the path.