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.

asked Sep 25, 2013 at 15:40
2
  • you cannot get access to the python-egg file , it forbidden Commented Sep 25, 2013 at 15:43
  • @drabo2005 permission issue? those two folders' owner is me and the permission level is drwxrwsr-x, which I think is good enough. Right? Commented Sep 25, 2013 at 15:45

1 Answer 1

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"

answered Sep 25, 2013 at 15:49
Sign up to request clarification or add additional context in comments.

6 Comments

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...
I've updated my answer with a link that might help you understand how eggs work
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.
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?
Just a folder which contains the module of pyes(python elastic search) and urllib3 (one of the dependencies)
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.