0

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.

Community
  • 1
  • 1
B.Mr.W.
  • 18,910
  • 35
  • 114
  • 178

1 Answers1

1

I quote:

http://peak.telecommunity.com/DevCenter/PythonEggs

.egg files are simply renamed zip files.

Open the egg with your zip program, or just rename the extension to .zip, and extract.

"A small introduction to Python Eggs"

Community
  • 1
  • 1
Paco
  • 4,520
  • 3
  • 29
  • 53
  • It might exist as a zipped file in Windows but in Linux I cannot see how it is zipped. However, your answer is very inspiring and I tried to add those two egg folders into the Python path and it worked now.. I am wondering why python setup.py install didn't add that for me... – B.Mr.W. Sep 25 '13 at 15:57
  • I've updated my answer with a link that might help you understand how eggs work – Paco Sep 25 '13 at 16:00
  • Do you know why the python install prefix command doesn't add the new created egg folders to the python path? Is there anything I can do to auto include the egg folders in this case. – B.Mr.W. Sep 25 '13 at 16:19
  • No I don't know. I actually don't really use eggs manually. The only thing I do with them is installing them from pypi. What is this egg? – Paco Sep 25 '13 at 16:27
  • Just a folder which contains the module of pyes(python elastic search) and urllib3 (one of the dependencies) – B.Mr.W. Sep 25 '13 at 16:52
  • `sudo pip install pyes urllib3` ? – Paco Sep 25 '13 at 17:06