Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

python - How to install setuptools?

I'm trying to install setuptools. When I run "sh setuptools-0.6c9-py2.4.egg" I get the following message:

Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-26338.write-test'

It is expectable, since I do not have root permissions on the system. Some how I came to the idea of creating a "Virtual" Python.

I download "virtual-python.py" and run it using the site-wide Python. It creates "lib", "bin" and "include" sub-directories in my home-directory. In the end of the output of "virtual-python.py" I see the following message:

You're now ready to download ez_setup.py, and run /home/myname/bin/python ez_setup.py

I download this file and run it. But than I get the same error message:

Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-925.write-test'

OK. I use "prefix" to force ez_setup.py to write to the local directory:

/home/myname/bin/python ez_setup.py --prefix=~

And then I get:

  • You can set up the installation directory to support ".pth" files by
    using one of the approaches described here:

http://peak.telecommunity.com/EasyInstall.html#custom-installation-locations

So, I am redirected to the same page which I read before. So, I do not know what to do now.

I also have another hint:

  • You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.)

But if I type:

PYTHONPATH=/home/myname/lib/python2.4/site-packages

I still get the same result as if Python does not see my environment variables.

Can anybody, pleas, help me with that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just adding extra detail to what already have been said.

  1. Download tar.gz of the latest version of virtualenv.
  2. Unpack it.
  3. You don't even need to install it, just run virtualenv.py, for example:
    virtualenv-1.3.3/virtualenv.py mypyenv
    mypyenv virtual Python environment will be created in your current directory and it will contain easy_install ready to use.
  4. Activate it:
    source mypyenv/bin/activate
    or on Windows do:
    mypyenvScriptsactivate.bat
    Now, your PATH is set to point at Python executables under mypyenv. From this shell session, you will be able to easy_install whatever you want, and resulting stuff will be installed in the guts of mypyenv instead of your default Python location, thus obviating any need for admin privileges.

OS X Snow Leopard caveat:
For some reason, virtualenv-1.3.3 does not play well with built-in Python under /System/Frameworks. I had to build a separate version of Python from source, and installed it under /usr/local/python_2_6_2.
With that done, I used --python /usr/local/python_2_6_2/bin/python option with virtualenv.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...