Problem with virtualenv in Mac OS X

前端 未结 14 2050
情歌与酒
情歌与酒 2020-12-23 16:29

I\'ve installed virtualenv via pip and get this error after creating a new environment:

selenium:~ auser$ virtualenv new  
New pyt         


        
相关标签:
14条回答
  • 2020-12-23 17:10

    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.

    0 讨论(0)
  • 2020-12-23 17:12

    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.

    0 讨论(0)
  • 2020-12-23 17:13

    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:

    1. Make sure you're running the latest virtualenv (1.5.1, of this writting)
    2. 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)

    0 讨论(0)
  • 2020-12-23 17:15

    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.

    0 讨论(0)
  • 2020-12-23 17:20

    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.

    0 讨论(0)
  • 2020-12-23 17:22

    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.

    0 讨论(0)
提交回复
热议问题