[Python] Using VirtualEnv with multiple Python versions on windows

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have python 2.7.6 and 3.4.0 on my machine. The 2.7 version is on my path. I would like to set up a virtualenv using 3.4. There are many postings on SO and elsewhere that suggest I do the following from a command prompt:

    virtualenv -p c:\python34 myvirtualenv


    but this does not work for me. The console session has administrator privilege and UAC is off, however I get a permissions problem:

    F:\virtualenv>virtualenv -p c:\python34 myenv
    Running virtualenv with interpreter c:\python34
    Traceback (most recent call last):
    File "c:\python27\scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
    File "C:\Python27\lib\site-packages\virtualenv.py", line 779, in main
    popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env)
    File "C:\Python27\lib\subprocess.py", line 709, in __init__
    errread, errwrite)
    File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
    WindowsError: [Error 5] Access is denied


    I have also tried it specifically pointing to the 3.4 version of virtualenv, but without changing the path it ends up executing a mixed bag of 2.7 and 3.4 python files.

    The only way I could find to set up my virtual environment is to change my path to 3.4, run virtualenv then reset my path to 2.7, which defeats the point of the python switch on virtualenv.

    Thanks

    Continue reading...

Compartilhe esta Página