我下载了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。可以想象,其他人也可能有这种情况。

其他回答

如果您想在已经有pip3的情况下安装pip2:

# get the installer script
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py

# install pip
python get-pip.py

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。

避免sudo:

python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile

来自:

http://www.pip-command-not-found.com

它通过使用解决了我的问题

sudo easy_install pip

如果在Windows上并使用Python安装程序,请确保勾选“将Python添加到环境变量”选项。

安装后,重新启动shell并重试以查看pip是否存在。