问题描述
我试图设置virtualenv指向Maya 2013的可执行文件,以便可以从外壳程序在其中运行单元测试. Maya使用位于/usr/autodesk/maya/bin/mayapy
的自定义python 2.6可执行文件.我收到这些错误:
I'm trying to set up virtualenv to point at Maya 2013's executable so I can run unit tests inside it from the shell. Maya uses a custom python 2.6 executable located at /usr/autodesk/maya/bin/mayapy
. I get these errors:
$ virtualenv -p /usr/autodesk/maya/bin/mayapy mayapy
Running virtualenv with interpreter /usr/autodesk/maya/bin/mayapy
PYTHONHOME is set. You *must* activate the virtualenv before using it
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 2577, in <module>
main()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1081, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1289, in install_python
writefile(site_filename_dst, SITE_PY)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 445, in writefile
f = open(dest, 'wb')
IOError: [Errno 2] No such file or directory: 'mayapy/lib/python26.zip/site.py'
我已阅读 virtualenv的页面,virtualenv -h
的输出,一些基本的virtualenv像这个这样的文章,并在google和SO中搜索了virtualenv和maya + virtualenv配对,全部无济于事.
I've read virtualenv's page, the output of virtualenv -h
, a few basic virtualenv writeups like this one, and searched google and SO for both virtualenv and maya+virtualenv pairings, all to no avail.
这是详细的输出:
$ virtualenv -vv -p /usr/autodesk/maya/bin/mayapy mayapy
Running virtualenv with interpreter /usr/autodesk/maya/bin/mayapy
PYTHONHOME is set. You *must* activate the virtualenv before using it
Directory mayapy/lib/python2.6 already exists
Symlinking Python bootstrap modules
Cannot import bootstrap module: os
Ignoring built-in bootstrap module: posix
Cannot import bootstrap module: posixpath
Cannot import bootstrap module: nt
Cannot import bootstrap module: ntpath
Cannot import bootstrap module: genericpath
Cannot import bootstrap module: fnmatch
Cannot import bootstrap module: locale
Cannot import bootstrap module: encodings
Cannot import bootstrap module: codecs
Cannot import bootstrap module: stat
Cannot import bootstrap module: UserDict
File mayapy/lib/python2.6/lib-dynload/readline.so already exists
Cannot import bootstrap module: copy_reg
Cannot import bootstrap module: types
Cannot import bootstrap module: re
Cannot import bootstrap module: sre
Cannot import bootstrap module: sre_parse
Cannot import bootstrap module: sre_constants
Cannot import bootstrap module: sre_compile
File mayapy/lib/python2.6/lib-dynload/zlib.so already exists
Cannot import bootstrap module: warnings
Cannot import bootstrap module: linecache
Cannot import bootstrap module: _abcoll
Cannot import bootstrap module: abc
Directory mayapy/lib/python2.6/site-packages already exists
Writing mayapy/lib/python26.zip/site.py
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 2577, in <module>
main()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1081, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1289, in install_python
writefile(site_filename_dst, SITE_PY)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 445, in writefile
f = open(dest, 'wb')
IOError: [Errno 2] No such file or directory: 'mayapy/lib/python26.zip/site.py'
推荐答案
在不影响您的maya运行时环境的情况下,一种适合于单元测试的替代方法是在maya.standalone实例中运行测试.如果您的所有测试都包含以下内容:
An alternative that's good for unittesting without messing with your maya runtime environment is to run your tests inside an instance of maya.standalone. If your tests all include something like this:
import maya.standalone
try:
maya.standalone.initialize()
except:
pass # initialize raises if you call it more than once, but it's harmless if you catch it.
您可以从mayapy解释器运行它们,而无需在gui模式下运行maya.
you can run them from the mayapy intepreter without running maya in gui mode.
这篇关于virtualenv和Maya的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!