11

我刚刚使用 Homebrew 从 Python 3.4 升级到 Python 3.6。

输出状态:

Pip, setuptools, and wheel have been installed. To update them
  pip3 install --upgrade pip setuptools wheel
You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

我试着跑

pip3 install --upgrade pip setuptools wheel

但它不会升级 Python 3.6 的 pip。相反,它在 Python 3.4 中找到 pip3 并说“满足要求”:

Requirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Collecting setuptools
  Downloading setuptools-33.1.1-py2.py3-none-any.whl (472kB)
    100% |████████████████████████████████| 481kB 1.0MB/s 
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 5.7MB/s 
Installing collected packages: setuptools, wheel
  Found existing installation: setuptools 12.0.5
    Uninstalling setuptools-12.0.5:
      Successfully uninstalled setuptools-12.0.5
Successfully installed setuptools-33.1.1 wheel-0.29.0

当我检查 pip 版本时,它是 Python 3.4,而不是 3.6。我该如何解决这个问题?

$ pip3 -V
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)
4

3 回答 3

14

安装并尝试使用没有virtualenv.

但是,您可以告诉 Mac 上的终端使用哪个 Python pip:

python3.6 -m pip install --upgrade pip setuptools wheel

如果需要在较旧的 Python3 版本上使用 pip,可以将 python3.6 更改为 python3.4。

于 2017-01-17T02:13:15.767 回答
5

临时修复可能是:

alias "pip3.6"="python3.6 -m pip $1"

这将允许您去pip3.6 install somemodulepip3.6 install --upgrade somemodule

于 2017-01-28T17:26:17.583 回答
0

当我执行python36 -m pip3 install -r requirements.txt时,我得到了错误:

/usr/bin/python36: No module named pip3

我的解决方案如下:

python3.6 -m ensurepip    
python3.6 -m pip install -r requirements.txt
于 2018-09-19T01:50:15.093 回答