Python虚拟环境的最终版本是PIP,而不是创建它的版本.为什么以及如何解决此版本控制问题? [英] A Python virtual environment ends up with an older version of PIP than the one that created it... why and how can I fix this versioning issue?
问题描述
我的问题类似于关于 这只是检查解释器是否为2.7.15,现在我们生成的需求输出虽然比预期的要小,但是会发出警告(这是我不理解的): 我们现在将离开环境并在其外部冻结: 尽管我们在检查下一步时具有相同版本的python(如果我理解正确),但这里没有提供升级建议. 为什么要安装其他版本的pip?或许,为什么它在虚拟环境中默认使用其他版本?对我来说似乎很奇怪.如何确保每次创建新的虚拟环境时都不会发生这种情况?任何输入将是最有帮助的! 您在虚拟环境之外的 检查其 或 要升级 并在虚拟环境中升级 激活虚拟环境后. My question is similar to another that was asked about Python3 so perhaps the answer is the same one - if so, I´d appreciate it if somebody can clarify this and go the step further of answering the additional questions posted here since there is, really, not a good answer there as to WHY it happens and HOW to avoid it without unintended consequences. Perhaps with 2.7 there is a better one? I don´t understand the following sequence where a virtual environment in my MAC OS ends up with a version of PIP that´s older than the version it created it: We´ve made sure the interpreter is 2.7.15 This is just a check that the interpreter is 2.7.15 and now we generate the requirements output which is small as expected but which gives this warning (which is what I DON´T understand): We´ll now leave the environment and do freeze outside it: No suggestion for upgrade is given here despite the fact that we have the SAME version of python (if I understand correctly) as we check next: Why did it install a different version of pip? Or perhaps, why does it default to a different version inside the virtual environment? It seems very odd to me. How can I make sure this does not happen every time I create a new virtual environment? Any input would be most helpful! Your or To upgrade that And to upgrade after activating the virtual env. 这篇关于Python虚拟环境的最终版本是PIP,而不是创建它的版本.为什么以及如何解决此版本控制问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!(env) dhcp--41:VO$ pip freeze
wheel==0.26.0
You are using pip version 8.0.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env) dhcp--41:VO$ deactivate
dhcp--41:VO$ pip freeze
absl-py==0.2.0
dhcp-18--41:VO$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
pip
是/usr/local/bin/pip
,这很可能意味着它使用了/usr/local/bin/python
或/usr/bin/python
.但是,您已经使用其他python-/usr/local/Cellar/python@2/2.7.15/bin/python
创建了虚拟环境.您可以使用dhcp--41:VO$ virtualenv -p
/usr/local/Cellar/python@2/2.7.15/bin/python env
Running virtualenv with interpreter
/usr/local/Cellar/python@2/2.7.15/bin/python
New python executable in /Users/jbs/PycharmProjects/VOSW- VWN/env/bin/python2.7
Also creating executable in /Users/jbs/PycharmProjects/VOSW-VWN/env/bin/python
Installing setuptools, pip, wheel...done.
pip
版本
/usr/local/Cellar/python@2/2.7.15/bin/pip --version
/usr/local/Cellar/python@2/2.7.15/bin/python -m pip --version
pip
,您需要运行/usr/local/Cellar/python@2/2.7.15/bin/python -m pip install -U pip
pip
python -m pip install -U pip
dhcp--41:VO$ virtualenv -p
/usr/local/Cellar/python@2/2.7.15/bin/python env
Running virtualenv with interpreter
/usr/local/Cellar/python@2/2.7.15/bin/python
New python executable in /Users/jbs/PycharmProjects/VOSW- VWN/env/bin/python2.7
Also creating executable in /Users/jbs/PycharmProjects/VOSW-VWN/env/bin/python
Installing setuptools, pip, wheel...done.
dhcp--41:VO$ source env/bin/activate
(env) dhcp--41:VO jbs$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(env) dhcp--41:VO$ pip freeze
wheel==0.26.0
You are using pip version 8.0.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env) dhcp--41:VO$ deactivate
dhcp--41:VO$ pip freeze
absl-py==0.2.0
dhcp-18--41:VO$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
pip
outside virtual environment is /usr/local/bin/pip
which most probably means it uses /usr/local/bin/python
or /usr/bin/python
. But you've created the virtual environment using a different python — /usr/local/Cellar/python@2/2.7.15/bin/python
. You can check its pip
version with/usr/local/Cellar/python@2/2.7.15/bin/pip --version
/usr/local/Cellar/python@2/2.7.15/bin/python -m pip --version
pip
you need to run/usr/local/Cellar/python@2/2.7.15/bin/python -m pip install -U pip
pip
inside the virtual envpython -m pip install -U pip