virtualenv返回错误' Operation not Permitted'

时间:2015-02-21 20:49:21

标签: django python-2.7 virtualenv

我使用的是命令virtualenv --no-site-packages django-env,但我遇到了以下错误

Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 1416, in install_python
    os.symlink(py_executable_base, full_pth)
OSError: [Errno 1] Operation not permitted

所以我想在我的终端上使用命令sudo virtualenv --no-site-packages django-env来避免任何操作系统冲突,但它会抛出以下错误,请看一下

Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 1204, in install_python
    copyfile(stdinc_dir, inc_dir, symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 479, in copyfile
    copyfileordir(src, dest, symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 454, in copyfileordir
    shutil.copytree(src, dest, symlink)
  File "/usr/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
shutil.Error: [('/usr/include/python2.7/numpy', 'django-env/include/python2.7/numpy', '[Errno 1] Operation not permitted')]

我正在使用Ubuntu 14.04和Python 2.7.6

我无法确定导致错误的原因。

4 个答案:

答案 0 :(得分:2)

在已安装的驱动器上运行 virtualenv 时,我遇到了类似的错误。对我来说,“--always-copy”选项解决了这个问题。

答案 1 :(得分:1)

由于安全原因,默认情况下,VirtualBox将禁止在已安装的共享文件夹中创建符号链接。

但是,您可以使用以下命令手动启用它。

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

之后,应正确引导虚拟环境。不要忘记关闭VM,以使此设置生效。

有关更多详细信息,请参考此VirtualBox的票证:https://www.virtualbox.org/ticket/10085

答案 2 :(得分:0)

在您的家中尝试这些命令

1.sudo easy_install virtualenv
2.mkdir virt_env
3.virtualenv virt_env / test1
4.source test1 / bin / activate
5.pip install django == 1.7.4

之后 django-admin.py startproject project_name

答案 3 :(得分:0)

关于开发文件夹的所有权:

在虚拟机安装的驱动器上运行virtualenv时遇到类似的错误。切换到虚拟机上的目录运行正常。

一切顺利。