views:

972

answers:

3

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?

+1  A: 

Virtualenv comes with setuptools pre-installed, I believe. I know that it at least comes with easy_install. You should then be able to run:

/home/myname/bin/easy_install setuptools

This should install the newest version of setuptools on your virtualenv.

Evan Fosmark
+1  A: 

You have to activate your virtualenv first, else you just have a bunch of folders. Use the full path to the scripts in your virtual env's bin or do source bin/activate

THC4k
A: 

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:
    mypyenv\Scripts\activate.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.

Pavel Repin