英文:
Python venv pip is always outdated
问题
以下是您要翻译的内容:
"Whenever I create a fresh Python 3.11 virtual environment using venv
, the provided pip
always prompts me to update to the latest version, even though my base version appears to be up to date
$ python3.11 -m pip --version
pip 23.0.1 from /opt/homebrew/lib/python3.11/site-packages/pip (python 3.11)
$ python3.11 -m venv venv
$ source venv/bin/activate.fish
(venv) $ pip install requests
...
Successfully installed ...
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
Why doesn't the virtual environment have the newest release to begin with? Is there a way I can manually set it for future virtual environments? I'd like to not have to deal with this slight inconvenience every time I create a new virtual environment."
英文:
Whenever I create a fresh Python 3.11 virtual environment using venv
, the provided pip
always prompts me to update to the latest version, even though my base version appears to be up to date
$ python3.11 -m pip --version
pip 23.0.1 from /opt/homebrew/lib/python3.11/site-packages/pip (python 3.11)
$ python3.11 -m venv venv
$ source venv/bin/activate.fish
(venv) $ pip install requests
...
Successfully installed ...
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
Why doesn't the virtual environment have the newest release to begin with? Is there a way I can manually set it for future virtual environments? I'd like to not have to deal with this slight inconvenience everytime I create a new virtual environment.
答案1
得分: 3
The venv
module uses the ensurepip
module to install a hard-coded version of pip
that is bundled with ensurepip
itself. While pip
is not part of the standard library, ensurepip
is. It does this, I believe, for a couple of reasons:
- You know exactly what version of
pip
will initially be installed for a given version of Python, no matter what machine you are using. - You can create a virtual environment without needing a network connection to download
pip
from PyPI or elsewhere.
You can see the wheel used to install pip
by looking in the directory containing the ensurepip
package.
>>> import pathlib, ensurepip
>>> list(pathlib.Path(ensurepip.__file__).parent.glob('*/pip*'))
[PosixPath('[...]/python3.9/ensurepip/_bundled/pip-21.3.1-py3-none-any.whl')]
英文:
The venv
module uses the ensurepip
module to install a hard-coded version of pip
that is bundled with ensurepip
itself. While pip
is not part of the standard library, ensurepip
is. It does this, I believe, for a couple of reasons:
- You know exactly what version of
pip
will initially be installed fora given version of Python, no matter what machine you are using. - You can create a virtual environment without needing a network connection to download
pip
from PyPI or elsewhere.
You can see the wheel used to install pip
by looking in the directory containing the ensurepip
package.
>>> import pathlib, ensurepip
>>> list(pathlib.Path(ensurepip.__file__).parent.glob('*/pip*'))
[PosixPath('[...]/python3.9/ensurepip/_bundled/pip-21.3.1-py3-none-any.whl')]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论