I\'ve installed virtualenv
via pip
and get this error after creating a new environment:
selenium:~ auser$ virtualenv new
New pyt
I had this same issue, and I can confirm that the problem was with an outdated virtualenv.py
file.
It was not necessary to do a whole install --upgrade.
Replacing the virtualenv.py
file with the most recent version sufficed.
Open terminal and type /Library/Frameworks/Python.framework/Versions/
then type ls /Library/Frameworks/Python.framework/Versions/2.7/bin/
if you are using Python2(or any other else).
Edit ~/.bash_profile and add the following line:
export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin/
cat ~/.bash_profile
In my case the content of ~/.bash_profile is as follows:
export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin/
Now the virtualenv command should work.
I've run across this problem myself. I wrote down the instructions in a README, which I have pasted below....
I have found there are two things that work:
If you're using a non system Python as your standard Python (which python to check) Forcefully use the System supplied one.
Instead of virtualenv thing
use /usr/bin/python2.6 PATH/TO/VIRTUALENV thing
(or whatever which
python
returned to you - this is what it did for me when I ran into this issue)
The above solutions failed for me, but the following worked:
python3 -m venv --without-pip <ENVIRONMENT_NAME>
. <ENVIRONMENT_NAME>/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
It's hacky, but yes, the core problem really did just seem to be pip.
Just in case there's someone still seeking for the answer.
I ran into this same problem just today and realized since I already have Anaconda installed, I should not have used pip install virtualenv
to install virtual environment as this would give me the error message when trying to initiate it later. Instead, I tried conda install virtualenv
then entered virtualenv env_mysite
and problem solved.
Like @RyanWilcox mentioned, you might be inadvertently pointing virtualenv
to the wrong Python installation. Virtualenv comes with a -p
flag to let you specify which interpreter to use.
In my case,
virtualenv test_env
threw the same error as yours, while
virtualenv -p python test_env
worked perfectly.
If you call virtualenv -h
, the documentation for the -p
flag will tell you which python it thinks it should be using; if it looks wonky, try passing -p python
. For reference, I'm on virtualenv 1.11.6.