0

I have python2.6 as my default python and I've been using distribute easy_install to install packages in ~/.local. easy_install has many issues and I'd like to switch to pip, while at the same time upgrading to python2.7 from python2.6. My existing pip version is tied to python2.6 and always looks in ~/.local/lib/python2.6 for packages. This means I have to install pip again with Python2.7 but it seems like this cannot be done with the existing python2.6 pip, right?

Therefore I tried to download pip and install it like this:

python2.7 setup.py install --prefix=~/.local

Note that I do not have root, so I have to install pip locally. When I try this I get:

Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    from setuptools import setup
ImportError: No module named setuptools

How can I fix this situation? I obviously cannot install setuptools with pip, because I can't install pip... all I want to do is link up pip with python2.7, upgrade pip and then install everything with pip and forget about easy_install and the old python2.6 and its packages.

When I try the answer below, I get:

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/user/.local/lib/python2.7/site-packages

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).

I had to manually create (with mkdir) the directory:

~/.local/lib/python2.7/site-packages

This seems broken... it worked once I did it, but why does it require manual creation of a directory?

thanks.

1 Answers1

1

You need to install setuptools first; it has it's own installation script (it's part of the egg file):

wget "http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg"
sh setuptools-0.6c11-py2.7.egg --prefix=~/.local

Note that it, too, supports a --prefix= option. It'll find your python2.7 binary (and not the 2.6 version) because you downloaded the 2.7 egg version.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343