为 Python 3.6 更新 pip3?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41688016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:27:03  来源:igfitidea点击:

Update pip3 for Python 3.6?

pythonpiphomebrewpython-3.6

提问by user2989813

I just upgraded from Python 3.4 to Python 3.6 using Homebrew.

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

The output states:

输出状态:

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

I tried to run

我试着跑

pip3 install --upgrade pip setuptools wheel

But it does not upgrade pip for Python 3.6. Instead it finds pip3 in in Python 3.4 and says 'requirement satisfied':

但它不会为 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

When I check the pip version, it is in Python 3.4, not 3.6. How do I resolve this?

当我检查 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)

回答by Moses Koledoye

Not a good idea to install and try to use Python3.4 and 3.6 without virtualenv.

安装并尝试使用 Python3.4 和 3.6 而没有virtualenv.

You can however tell the terminal on your mac which Python pip to use with:

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

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

You can change python3.6 to python3.4 if you need to use pip on the older Python3 version.

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

回答by reee

A temporary fix could be:

临时修复可能是:

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

This will allow you to go pip3.6 install somemoduleor pip3.6 install --upgrade somemodule

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

回答by xjzhou

When I execute python36 -m pip3 install -r requirements.txt, I got the error:

当我执行时python36 -m pip3 install -r requirements.txt,出现错误:

/usr/bin/python36: No module named pip3

My solution is the following:

我的解决方案如下:

python3.6 -m ensurepip    
python3.6 -m pip install -r requirements.txt