3

I am running Windows 8.1 with python 2.7.11, 3.4.3, 3.5.1. Only python 2.7 is added to path. Im trying to create a virtual environment using the following command in cmd (with administrative privilages)

virtualenv -p B:\Apps\Python\2.7 sympy2.7

It results in the following error

Running virtualenv with interpreter B:\Apps\Python\2.7
Traceback (most recent call last):
File "b:\apps\python\2.7\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "b:\apps\python\2.7\lib\runpy.py", line 72, in _run_code exec code in run_globals
File "B:\Apps\Python\2.7\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "b:\apps\python\2.7\lib\site-packages\virtualenv.py", line 665, in main popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env)
File "b:\apps\python\2.7\lib\subprocess.py", line 710, in __init__ errread, errwrite)
File "b:\apps\python\2.7\lib\subprocess.py", line 958, in _execute_child startupinfo)
WindowsError: [Error 5] Access is denied

I tried implemeting the solution given in this Stack Overflow question but none of them work. For eg, the command

py -2.7 -m virtualenv sympy2.7

or this command,

virtualenv -p B:\Apps\Python\2.7\python.exe sympy2.7   

results in

New python executable in A:\Programming\Open Source\Sympy\environments\sympy2.7\Scripts\python.exe
ERROR: The executable "A:\Programming\Open Source\Sympy\environments\sympy2.7\Scripts\python.exe" could not be run: [Error 5] Access is denied

Can anyone help me troubleshoot.

Community
  • 1
  • 1
Almond Pie
  • 71
  • 1
  • 6

5 Answers5

8

For me, the solution was to refer to the executable file instead of the folder. The 'Access is denied' error message is quite misleading.

C:\Installs\Python_3.8>virtualenv -p C:\Installs\Python_3.8 tensorflow_env
# Output: RuntimeError: failed to query C:\Installs\Python_3.8 with code 13 err: 'Access is denied'

C:\Installs\Python_3.8>virtualenv -p C:\Installs\Python_3.8\python.exe tensorflow_env
# Output: created virtual environment CPython3.8.0.final.0-64 in 2504ms
Mikko Haavisto
  • 991
  • 7
  • 10
2

This is a bug in virtualenv due to spaces in the path. It was incorrectly quoting the path to the newly created python.exe, causing it to not be found.

pypa/virtualenv#936 is the fix for the issue, but the workaround is to only create virtual environments in paths without spaces.

Zooba
  • 11,221
  • 3
  • 37
  • 40
0

This is a bug in virtualenv due to spaces in the path. Corrent the whole path to the env without any space eg: E:\Works\project_2017

Bibin Joseph
  • 499
  • 4
  • 3
0

Use this command virtualenv -p "B:\Apps\Python\2.7 sympy2.7"

0

Try this py -m virtualenv -p python3 mytest

fjkjava
  • 1,414
  • 1
  • 19
  • 24