How to force virtualenv to install latest setuptools and pip from pypi?

一笑奈何 提交于 2019-11-29 01:20:08
cdwilson

It's not supported for security reasons.

Using virtualenv.py as an isolated script (i.e. without an associated virtualenv_support directory) is no longer supported for security reasons and will fail with an error. Along with this, --never-download is now always pinned to True, and is only being maintained in the short term for backward compatibility (Pull #412).

I can't use the --extra-search-dir option either because it's currently broken https://github.com/pypa/virtualenv/issues/327

Looks like the only option is to simply wait for the virtualenv maintainers to update the bundled packages?

You can upgrade pip after installing your virtualenv by using pip install -U pip.

I'm sure you could write a bootstrap-script to automate this step.

I needed the latest setuptools library, and the --extra-search-dir flag wasn't working for me (even though it's been fixed apparently).

However, making a virtualenv without setuptools and then installing directly from PyPi worked great. E.g. to set up a virtualenv called test:

virtualenv --no-setuptools test
source test/bin/activate
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
easy_install pip

Testing with

python -c 'import setuptools; print setuptools.__version__'

shows the right version.

I ran into the same problem, and I fixed it by upgrading setuptools.

If env is your virtual env, run the following:

$ env/bin/pip install --upgrade setuptools

pymarco

Building on ematsen's excellent answer I made a bash script that works with virtualenvwrapper

#!/bin/bash
source `which virtualenvwrapper.sh`
mkvirtualenv --no-setuptools $1
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
rm setuptools-*.zip
easy_install pip

# for python version < 2.7.9
# https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
pip install urllib3[secure]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!