我下载了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的最新版本

它有很多下载链接,比如numpy和scipy

进入终端,输入如下命令:—

sudo easy_install pip

对于Python安装包,请检查此选项

Requirements for Installing Packages This section describes the steps to follow before installing other Python packages. Install pip, setuptools, and wheel If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version: On Linux or OS X: pip install -U pip setuptools On Windows: python -m pip install -U pip setuptools If you’re using a Python install on Linux that’s managed by the system package manager (e.g “yum”, “apt-get” etc…), and you want to use the system package manager to install or upgrade pip, then see Installing pip/setuptools/wheel with Linux Package Managers Otherwise: Securely Download get-pip.py 1 Run python get-pip.py. 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.

其他回答

解决bash: pip:命令在Mac中找不到的问题

在Mac 1上有两个版本,一个是2.7,另一个是3.7

当我说sudo easy_install pip时,pip在2.7下被安装 当我说sudo easy_install-3.7 pip时,pip在3.7下安装

但是,每当我需要做pip安装时,我想在python3.7下安装这个包,所以我在.bash_profile中设置了一个别名(别名pip=pip3)。

所以现在,只要我执行pip install <package_name>,它就会安装在python3.7下

我花了很长时间浏览本页上的所有答案,但在s-walsh的OP问题的评论中找到了一个对我有用的答案

答案是使用pip3:

$ pip3 install <name-of-install>

(背景:我的操作系统是使用AWS的Amazon linux。它看起来和红帽很相似,但似乎是精简了一些。)

退出shell,然后打开一个新的shell。pip命令现在可以工作了。

这就解决了这个地方的问题。

你可能还想知道:安装软件的pip命令需要像下面这个例子(以jupyter为例)那样编写,才能在我的系统上正确工作:

PIP安装jupyter——user

具体来说,请注意缺少sudo,并且存在——user

如果pip docs对这一切说了什么,那就太好了,但我猜那需要输入更多的字符。

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

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

问题似乎是你的python版本和你想要安装的库在版本上不匹配。例如:如果Django是Django3,而你的python版本是2.7,你可能会得到这个错误。

“安装后正在运行'python',仍然运行python 2.6, PATH没有更新。”

1-安装最新版本的Python 2-手动更改PATH为python38并比较它们。 3-尝试重新安装。

我用最新版本的Python手动替换PATH解决了这个问题。 至于Windows:;C:\python38\Scripts