How to install pip in a new python installation

2019-02-02 04:01发布

I recently installed python 2.7.2 on my Mac running OSX 10.6.8. Previously, I had version 2.6. I set my path in .bash_profile as follows:

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH

so that when I run python it will refer to my new installation. It does.

I would also like to use pip with my new installation, but the problem is that I already have the current version of pip installed at

/usr/local/bin/pip.

I tried to re-install pip with:

easy_install pip

But, of course this does not put pip in the desired new directory

/usr/local/share/python/pip

but simply refers to the existing version in /usr/local/bin/pip.

Can someone tell me how to fix this?

I would like to then use pip to install NumPy and SciPy in the correct directory (I was having trouble getting the SciPy installation to work with my old version of python, hence the new install).

If you'd like, you can visit the website where I found instructions for installing python 2.7, creating/updating my .bash_profile, installing pip, and NumPy and SciPy. Might provide some insight, or I'm happy to give more details if needed. Thanks! http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/#python

7条回答
再贱就再见
2楼-- · 2019-02-02 04:49

Install distribute as per the instructions at http://pypi.python.org/pypi/distribute . Make sure you specify the full path to the python executable (/usr/local/share/python/python or smth in your case).

$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ /usr/local/share/python/python distribute_setup.py

Then you should have /usr/local/share/python/easy_install.

After that, run:

$ /usr/local/share/python/easy_install pip

Then you should have /usr/local/share/python/pip.

Depending on the ordering of things in your PATH, either your old, or the newly installed pip is executed when you execute the pip command, so you either might have to adapt your PATH, or specify the full path to /usr/local/share/python/pip when installing eggs.

(shameless plug: In any case, you might consider using virtualenv for installing packages into a "project" specific isolated environment, as opposed to installing them globally.)

查看更多
登录 后发表回答