Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install pip in a new python installation

Tags:

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

like image 921
python4ecology Avatar asked Mar 21 '12 01:03

python4ecology


People also ask

How do I install pip to another version?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .

Does Python 3.10 have pip?

The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.

Why can't I install pip in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.


2 Answers

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.)

like image 57
Erik Kaplun Avatar answered Oct 02 '22 15:10

Erik Kaplun


I needed to uninstall brew's python.

Then, I was left with python v2.7.6

Next to install, pip I ran

sudo easy_install pip 

installed fine and working

like image 25
cooldude8 Avatar answered Oct 02 '22 17:10

cooldude8