How do I control the version of pip
which is used in a freshly created venv
?
By default, it uses a vendored pip distribution which may be out of date or unsuitable for whatever other reason. I want to be able to create a venv
with a user-specified version of pip installed initially, as opposed to creating one and then upgrading the pip installation from within the env.
For me, I just upgraded pip/virtualenv/virtualenvwrapper on my machine (not inside the virtualenv). Subsequently created virtualenvs had the updated version.
deactivate pip install --upgrade pip virtualenv virtualenvwrapper mkvirtualenv ...
From reading the source of virtualenv, it looks like pip is installed from a source tarfile included with virtualenv. In virtualenv 1.10.1, it is pip-1.4.1.tar.gz
in the site-packages/virtualenv_support
directory (it gets setuptools
from the same place). You could feasibly replace that archive to control the version; virtualenv.py, at least the version I have, doesn't care which version of pip is there:
if not no_pip: install_sdist('Pip', 'pip-*.tar.gz', py_executable, search_dirs)
You could also pass the --no-pip
option and then install the version you want from source.
In virtualenv 1.11, it looks for a wheel file (e.g. pip-*.whl
) instead of a tar.gz
, but other than that it acts the same way (thanks @wim for the update).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With