我下载了pip并运行python setup.py install,一切正常。本教程的下一步是运行pip install <lib,你想要>,但在它尝试在线查找任何东西之前,我得到一个错误“bash: pip: command not found”。

这是在Mac OS x上,我假设在运行setup。py时,某种路径设置没有正确设置。我如何进一步调查?我需要检查什么才能更好地了解问题的确切原因?

编辑:我还尝试了为Mac安装Python 2.7,希望友好的安装过程会做一些管理工作,比如编辑PATH和任何其他需要发生的事情,以便根据教程工作,但这并不管用。安装后,运行'python'仍然运行python 2.6, PATH没有更新。


当前回答

为了克服这个问题,我安装了python-pip。

结果发现我的虚拟机还没有安装pip。可以想象,其他人也可能有这种情况。

其他回答

2020年更新:

对于当前的Debian/Ubuntu,使用

apt-get install python3-pip

安装pip3。


2013年的旧答案(easy_install现在已弃用):

使用setuptools安装pip: sudo easy_install pip

(我知道我上面的回答与klobucar的回答是多余的,但我还不能添加注释),所以这里有一个解决sudo的答案:easy_install:命令在Debian/Ubuntu上找不到:sudo apt-get install python-setuptools

同样,对于python3,使用easy_install3和python3-setuptools。

对于Python 3,使用apt-get install python3-pip。

基于这个stackoverflow的答案和这个线程上的一些答案,我在rc文件中创建了一个别名: 别名pip="python3 -m pip"

这个问题似乎有很多不同的答案,但这似乎是最佳实践方法。

更新后的安装pip3命令为:

sudo apt-get install python3-pip

假设你有互联网,请看: https://pip.pypa.io/en/stable/installing/

主要经营:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

and

python get-pip.py

使用apt-get安装会为用户安装一个系统范围的pip,而不仅仅是本地的pip。试试这个命令让pip在你的系统上运行…

$ sudo apt-get install python-pip python-dev build-essential

然后pip将安装没有任何问题,你将能够使用“sudo pip…”。