如何更改virtualenv在没有sudo的情况下运行所需的所有权限?

时间:2012-04-02 03:27:28

标签: python django permissions virtualenv

$ virtualenv --no-site-packages myenv
The --no-site-packages flag is deprecated; it is now the default behavior.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 928, in main
    never_download=options.never_download)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 1029, in create_environment
    site_packages=site_packages, clear=clear))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 1154, in install_python
    mkdir(lib_dir)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.7.1.2-py2.7.egg/virtualenv.py", line 399, in mkdir
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: 'myenv'

我一直在努力弄清楚如何能够让virtualenv创建一个没有sudo的新环境。

1 个答案:

答案 0 :(得分:5)

您似乎正在尝试在您无权访问的位置创建环境。你在哪里尝试创造环境?如果您在共享托管环境中执行此操作,则需要在主目录中创建virtualenv。

或者,使用virtualenvwrapper,这应该处理您需要做出的大多数决定(比如存储您的环境的位置)。