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:27

Just wanted to say that I found a way to get around my problem. I don't know that I can explain it perfectly, since I am not very good at understanding what I am doing with this stuff just yet! But, the problem seems to have been with my PATH. I removed the PATH that I posted in my original question, and then used easy_install pip. It went straight to python 2.7.2 (my new version) with no problem. I then successfully used pip to install NumPy and SciPy in the correct location, and they both work. Thanks to ErikAllik and FakeRainBrigand for taking the time to look into it!

查看更多
Explosion°爆炸
3楼-- · 2019-02-02 04:28

Just so that people knew, ATM we can install PIP by downloading get-pip.py from the page with docs and run it like this:

c:\python27\python.exe get-pip.py

BTW, Python 3.4 comes with PIP pre-installed.

查看更多
唯我独甜
4楼-- · 2019-02-02 04:37

A few days ago I had a friend who was starting Python Programming and needed help with the same issue: installing pip. There are debates over which one to choose between easy_install and pip and it seems everybody is heading the pip direction. Either way, installing either of them can be frustrating.

You can use this simple tutorial : installing pip package manager the easy way

Here are what you should keep in mind as you follow the above guide:

  • If you already have an older version installed, uninstall it or totally remove the python installation
  • Once that is cleared, download an install Python.
  • After that, download ez_setup.py file and save it to your desktop - easily accessible from the command line
  • Now run it from the command line and it will install easy_install for you after which,
  • You can use it to install pip.

Once again, you can do this or use the above link to find a simple step-by-step guide on how to get it installed on your computer. Good luck.

查看更多
淡お忘
5楼-- · 2019-02-02 04:38

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

查看更多
太酷不给撩
6楼-- · 2019-02-02 04:38

I had a similar issue, try this:

$ python -m pip install --upgrade --force-reinstall pip

This will force reinstall pip with whatever version of python you use including installing the binary.

查看更多
Rolldiameter
7楼-- · 2019-02-02 04:39

One of the command line options lets you choose where to install to.

--install-dir (-d) install package to DIR

So something like - # easy_install pip -d /usr/local/share/python

(Please correct me if I'm wrong.)

查看更多
登录 后发表回答