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'
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.
Here's the verbose output:
$ 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'
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:
you can run them from the mayapy intepreter without running maya in gui mode.
Download the latest virtualenv and call it virtualenv with the version of python you want to virtualize: