“OSError: [Errno 13] 权限被拒绝”错误

“OSError: [Errno 13] 权限被拒绝”错误

我正在尝试创建一个虚拟环境,但遇到了这个错误:

user@mylaptop:~$ virtualenv -p ~/Public/Programming/project1/
Running virtualenv with interpreter /home/user/Public/Programming/Project1/
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==12.0.6', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 784, in main
    popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

我应该怎么办?

答案1

您尚未指定用于在~/Public/Programming/project1/目录中创建虚拟环境的 Python 解释器。

man virtualenv

-p PYTHON_EXE,--python=PYTHON_EXE
The Python interpreter to use to create the new environment.

-p选项要求下一个参数是新环境所基于的 Python 解释器。但是您错过了该参数,并virtualenv认为您希望将环境基于~/Public/Programming/project1/解释器。但是那里没有可用的解释器,因此您得到了该结果OSError

如果你想使用 Python 2.7,正确的命令是:

virtualenv -p python2.7 ~/Public/Programming/project1/

对于 Python 3.4 来说,它将是:

virtualenv -p python3.4 ~/Public/Programming/project1/

相关内容