pyvenv 安装了错误的 pip 版本 [英] pyvenv installs wrong pip version
问题描述
我正在使用 pyvenv env
创建一个 virtualenv,但安装的 pip 版本已过时.我可以在虚拟环境中手动更新 pip,但我想自动获得正确的版本.
I'm creating a virtualenv with pyvenv env
but the installed pip version is outdated. I can manually update pip in the virtual env but I would like to have the correct version automatically.
没有激活venv:
~> pip -V
pip 7.1.2 from /usr/lib/python3.4/site-packages (python 3.4)
安装venv:
~> pyvenv env
~> source env/bin/activate.fish
激活 venv:
~> pip -V
pip 6.0.8 from /home/syntonym/test/env/lib/python3.4/site-packages (python 3.4)
我正在使用 arch 并且 pip 由 pip 和 pacman(arch 数据包管理器)管理,这可能不是一个好主意.我仍然不知道 pyvenv 从哪里获得 6.0.8 版本的 pip 或如何修复它.用 pacman 重新安装没有帮助.
I'm using arch and have pip managed by both, pip and pacman (the arch packet manager), which is probably not a good idea. I still have no idea from where pyvenv gets a 6.0.8 version of pip or how to fix it. Reinstalling with pacman did not help.
ensurepip 声称它已经是最新的:
ensurepip claims it's already up to date:
~> python -m ensurepip --upgrade
Ignoring indexes: https://pypi.python.org/simple
Requirement already up-to-date: setuptools in /usr/lib/python3.4/site-packages
Requirement already up-to-date: pip in /usr/lib/python3.4/site-packages
推荐答案
可以在虚拟环境下手动升级pip
You can upgrade pip in a virtual environment manually by executing
pip install -U pip
您正面临这个问题,因为 venv
使用 ensurepip 将 pip
添加到新环境中:
You are facing this problem, because venv
uses ensurepip to add pip
into new environments:
除非给出了 --without-pip 选项,否则将调用 ensurepip 以引导 pip 进入虚拟环境.
Unless the --without-pip option is given, ensurepip will be invoked to bootstrap pip into the virtual environment.
Ensurepip 包不会从 Internet 下载或从其他任何地方获取文件,因为所有必需的组件都已包含在包中.这样做会增加安全漏洞,因此不受支持.
Ensurepip package won't download from the internet or grab files from anywhere else, because all required components are already included into the package. Doing so would add security flaws and is thus unsupported.
Ensurepip 并非旨在为您提供最新的 pip
,而只是一个"pip
.要获得最新的,请使用本文开头的手动方式.
Ensurepip is not designed to give you the newest pip
, but just "a" pip
. To get the newest one use the manual way at the beginning of this post.
这篇关于pyvenv 安装了错误的 pip 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!