Control the pip version in virtualenv

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


You cannot downgrade pip using pip, the solution is to install a specific version in your virtual environment:

virtualenv env -p python3.6 --no-pip
source env/bin/activate
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==18.1

This will allow you to keep using --process-dependency-links that was removed in pip 19.


It's easy enough to replace the pip that gets installed in your virtual environment. Within your virtual environment active, simply execute the following command:

pip install pip==1.4.1

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