简体   繁体   English

在VMWare中使用带有共享Windows文件夹的virtualenv

[英]Using virtualenv in VMWare with shared Windows folder

I currently use a linux VM in VMWare running on a Windows machine. 我目前在Windows机器上运行的VMWare中使用Linux VM。 I have a shared Windows folder for my projects that I access in linux via /mnt/hgfs/ 我有一个共享的Windows文件夹,我通过/ mnt / hgfs /在linux中访问我的项目

When I try to use virtualenv for my python projects I get an 'Operation not supported' error: 当我尝试为我的python项目使用virtualenv时,我得到一个'Operation not supported'错误:

joe@myserver:/mnt/hgfs/winwww/envtest# virtualenv env
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.7', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 928, in main
    never_download=options.never_download)
  File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1029, in create_environment
    site_packages=site_packages, clear=clear))
  File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1164, in install_python
    copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
  File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 430, in copyfile
    copyfileordir(src, dest)
  File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 405, in copyfileordir
    shutil.copytree(src, dest, True)
  File "/usr/lib/python2.6/shutil.py", line 173, in copytree
    raise Error, errors
shutil.Error: [('/usr/lib/python2.6/config/libpython2.6.so', 'env/lib/python2.6/config/libpython2.6.so', '[Errno 95] Operation not supported')]

I'm assuming this is due to Windows not being able to handle symbolic links because I can create my virtualenvs in other directories. 我假设这是由于Windows无法处理符号链接,因为我可以在其他目录中创建我的virtualenvs。

Has anyone worked out a way to make virtualenv work in shared Windows folders? 有没有人找到一种方法让virtualenv在共享的Windows文件夹中工作? I edit my code on my Windows machine which is why I use shared folders. 我在Windows机器上编辑代码,这就是我使用共享文件夹的原因。

Thanks. 谢谢。

The virtualenv does not need to be located next to your code, so even if you can't create it within your shared folder this shouldn't affect your ability to edit the code on windows and run it on your host platform. virtualenv不需要位于代码旁边,因此即使您无法在共享文件夹中创建它,也不会影响您在Windows上编辑代码并在主机平台上运行代码的能力。 It sounds to me like a bad idea anyway to attempt to share platform-specific files with multiple platforms. 无论如何,尝试与多个平台共享特定于平台的文件对我来说听起来像个坏主意。

This is the usefulness of the .pth files and if you're using setuptools with a setup.py within your project you can just $VENV/python setup.py develop which will link your project into the virtualenv, wherever it may be located. 这是.pth文件的有用性,如果您在项目中使用setupto与setup.py,您只需$VENV/python setup.py develop ,它将您的项目链接到virtualenv,无论它位于何处。 You can then run $VENV/python and your package will be in the sys.path and available for import. 然后,您可以运行$VENV/python ,您的包将在sys.path并可供导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM