pyvenv installs wrong pip version

和自甴很熟 提交于 2019-12-11 03:52:21

问题


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.

Without venv activated:

~> pip -V
pip 7.1.2 from /usr/lib/python3.4/site-packages (python 3.4)

Installing the venv:

~> pyvenv env
~> source env/bin/activate.fish

With venv activated:

~> pip -V
pip 6.0.8 from /home/syntonym/test/env/lib/python3.4/site-packages (python 3.4)

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.

EDIT:

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

回答1:


You can upgrade pip in a virtual environment manually by executing

pip install -U pip

You are facing this problem, because venv uses ensurepip to add pip into new environments:

Unless the --without-pip option is given, ensurepip will be invoked to bootstrap pip into the virtual environment.

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 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.



来源:https://stackoverflow.com/questions/32296580/pyvenv-installs-wrong-pip-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!