Python 我不断收到升级 pip 的消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51644402/
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
I keep getting a message to upgrade pip
提问by Maksim
Whenever I create a venv, I get a message asking me to upgrade pip. I run the command for upgrade, and it pops up again on another venv. How can I make this permanent.
每当我创建 venv 时,都会收到一条消息,要求我升级 pip。我运行升级命令,它在另一个 venv 上再次弹出。我怎样才能使它永久化。
Message:
信息:
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Update: Just received recommendation to read this possible duplicate answer: virtualenv use upgraded system default pip
更新:刚刚收到建议阅读这个可能的重复答案:virtualenv 使用升级的系统默认 pip
This does not solve my issue though. Why?
但这并不能解决我的问题。为什么?
My pip3
appears to already be up to date:
我的pip3
似乎已经是最新的:
C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip --version
pip 18.0 from c:\users\mkupfer\appdata\local\programs\python\python36-32\lib\sit
e-packages\pip (python 3.6)
C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip3 --version
pip 18.0 from c:\users\mkupfer\appdata\local\programs\python\python36-32\lib\sit
e-packages\pip (python 3.6)
C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip3 install --upgrade pip
Requirement already up-to-date: pip in c:\users\mkupfer\appdata\local\programs\p
ython\python36-32\lib\site-packages (18.0)
Solved
解决了
Solution: I was able to fix this altogether by using virtualenv
to create a new virtual environment. Not sure if this is a bug in venv
. I'll just use the package that works going forward. Thanks @James Lim for the answer.
解决方案:我能够通过使用virtualenv
来创建一个新的虚拟环境来完全解决这个问题。不确定这是否是venv
. 我将只使用可以正常工作的包。感谢@James Lim 的回答。
采纳答案by James Lim
The issue seems to be that newvirtual environments are using an old version of pip. Note that pip is installed from a source tarfile (or wheel) included with virtualenv, in the site-packages/virtualenv_support
directory.
问题似乎是新的虚拟环境正在使用旧版本的 pip。请注意,pip 是从site-packages/virtualenv_support
目录中包含在 virtualenv 中的源 tarfile(或轮子)安装的。
$ ls -l /path/to/site-packages/virtualenv_support
pip-9.1-py2.py3-none-any.whl
A quick way to workaround the problem is to make sure you upgrade pip whenever you create a new virtualenv, like so:
解决此问题的一种快速方法是确保在创建新的 virtualenv 时升级 pip,如下所示:
$ virtualenv venv
$ venv/bin/pip install -U pip
Alternatively, make sure you have the latest version of virtualenv. According to their release notes, virtualenv==16
is using pip==10
.
或者,确保您拥有最新版本的 virtualenv。根据他们的发行说明,virtualenv==16
正在使用pip==10
.
$ pip install -U virtualenv
Finally, since virtualenv looks for pip*.whl
in virtualenv_support
, this will also work:
最后,由于 virtualenv 查找pip*.whl
in virtualenv_support
,这也将起作用:
$ mv /path/to/site-packages/virtualenv_support/pip*.whl{,bak}
$ pip wheel -w /path/to/site-packages/virtualenv_support/ 'pip==18'
All new virtualenvs will use the version of pip that you installed into virtualenv_support
. However, this feels hacky.
所有新的 virtualenv 都将使用您安装到virtualenv_support
. 然而,这感觉很hacky。
(Attempted with virtualenv==16
. This results in all new virtualenvs with pip==18.)
(尝试使用virtualenv==16
。这会导致所有新的虚拟环境都带有 pip==18。)
回答by wowkin2
For me looks like you have multiple python environments and in one of them, there is not an upgraded pip. You have 2 options:
对我来说,您似乎有多个 python 环境,并且在其中一个环境中没有升级的 pip。您有 2 个选择:
- navigate to each of that folders and update each pip
- you can remove all of them, reinstall and use virtualenv in future with correct pip
- install some IDE (e.g. PyCharm) that can handle that automatically for you and show all issues visually
- 导航到每个文件夹并更新每个点
- 您可以删除所有这些,重新安装并在将来使用正确的 pip 使用 virtualenv
- 安装一些 IDE(例如 PyCharm),它可以为您自动处理并直观地显示所有问题
回答by wowkin2
Update pip from a bat file:
从 bat 文件更新 pip:
call .\venv\Scripts\activate
py -m pip install --upgrade pip
call deactivate
Or if you are in VS Code integrated Terminal
或者,如果您在 VS Code 集成终端中
& venv/Scripts/activate.ps1
py -m pip install --upgrade pip
回答by Krishna Kokila
when upgrading pip would uninstall the old version, but if old version is in a different place it cant,hence ending up in two different pip versions. Check your installations on your root PYTHONPATH. Also PYTHONPATH may not be same as system path.
升级 pip 时会卸载旧版本,但如果旧版本位于不同的位置,则无法卸载,因此最终会出现两个不同的 pip 版本。检查您在根 PYTHONPATH 上的安装。此外 PYTHONPATH 可能与系统路径不同。
回答by kiran beethoju
Here is the solution to your issue.
这是您问题的解决方案。
step 1: run this command in your shell or jupyter notebook it will securely download get-pip.py from pypa
第 1 步:在您的 shell 或 jupyter notebook 中运行此命令,它将安全地从 pypa 下载 get-pip.py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
step 2: run below code
第 2 步:运行下面的代码
python get-pip.py