我下载了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没有更新。


当前回答

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

安装后,重新启动shell并重试以查看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。

Python默认安装,但如果不安装,您可以使用CMD手动安装它(仅适用于Linux)

对于python3:

sudo apt install python3-pip 

对于python2

sudo apt install python-pip 

希望能有所帮助。

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

sudo easy_install 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

查看如何安装Pip文章了解更多信息。

截至2019年,

使用以下命令下载https://pip.pypa.io提供的get-pip.py: Curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

执行get-pip.py命令: Sudo python get-pip.py

安装完成后,运行该命令检查是否安装了pip。 皮普,版本

在安装pip后删除get-pip.py文件。 rm get-pip.py