gpt4 book ai didi

python - Virtualenv 没有创建环境

转载 作者:IT老高 更新时间:2023-10-28 21:16:38 25 4
gpt4 key购买 nike

我在 Ubuntu 12.04 上安装了 Virtualenv,并使用它在统一桌面下的示例项目上工作。我正在使用 VirtualBox,并且在统一桌面上遇到了一些问题,因此更改为 KDE 桌面。

我现在正在尝试创建一个新项目,但 virtualenv 不允许我在我的项目文件夹中创建一个新环境。在终端中,我导航到项目文件夹,键入 virtualenv venv 并收到以下错误消息:

Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in <module>
virtualenv.main()
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
never_download=options.never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1215, in install_python
copyfile(stdinc_dir, inc_dir)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 430, in copyfile
copyfileordir(src, dest)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 405, in copyfileordir
shutil.copytree(src, dest, True)
File "/usr/lib/python2.7/shutil.py", line 206, in copytree
raise Error, errors
shutil.Error: [('/usr/include/python2.7/numpy', 'venv/include/python2.7/numpy', '[Errno 30] Read-only file system')]

谁能帮我解决这个问题?我试过重新安装 virtualenv 但没有任何乐趣。谢谢

最佳答案

Virtualenv 正在使用符号链接(symbolic link)(shutil.copytree 使用它们,请参阅回溯)。禁用在 VirtualBox 共享文件夹中创建符号链接(symbolic link)。终端中的简单测试(在 guest 机器内):

$ ln -s testfile

你会得到 failed to create symbolic link './testfile': Read-only file systemProtocol error

您可以通过在主机上的终端(solution from schisamo)中执行来启用共享文件夹中的符号链接(symbolic link):

$ vboxmanage setextradata VM_NAME "VBoxInternal2/SharedFoldersEnableSymlinksCreate/NAME_OF_YOUR_SHARED_FOLDER" 1

将 VM_NAME 替换为虚拟机的名称,如 VirtualBox Manager 中所示:

VM_NAME example

和 NAME_OF_YOUR_SHARED_FOLDER 以及您可以在虚拟机设置中看到的共享文件夹的名称:

Shared folders settings

设置完成后,重启VirtualBox。

您可以使用

检查设置( 在主机上)
$ vboxmanage getextradata VM_NAME enumerate

Fix for Windows (Ahti Kitsik) (感谢 Bryan's answer )。


VirtualBox 为共享文件夹实现了符号链接(symbolic link) since version 4.0 (for Linux and Solaris)但是是 disabled since version 4.1.8出于安全原因。这可能就是为什么它首先对您有效,后来却无效的原因。

Documentation :

VirtualBox shared folders also support symbolic links, also called symlinks, under the following conditions:

  • The host operating system must support symlinks. For example, a Mac OS X, Linux, or Oracle Solaris host is required.
  • Currently only Linux and Oracle Solaris Guest Additions support symlinks.
  • For security reasons the guest OS is not allowed to create symlinks by default. If you trust the guest OS to not abuse the functionality, you can enable creation of symlinks for a shared folder as follows [see above]

关于python - Virtualenv 没有创建环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11265091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com