简体   繁体   中英

Maya Python compile for earlier version

I've made a system of distributing tools using a zip. The tools inside the zip seem to only like to run from pyc. One of my animators is using Maya 2013, which has an older version of python (2.6.4). I get a Magic Numbers error when he tries to run my files.

How can I compile my scripts to an older version of python?

If you're distributing pyc files you'll need to 'compile' them for the python major version you are targeting by running py_compile from an interpreter that's on the right version. You can probably do this using a 2.6.4 intepreter without actually running maya so if you don't have the same maya version but can grab an interpreter it will create 2.6.4 compatible pycs.

However you should also be able to distribute zipped .py files instead, which should be version independent (the main gotchas will be that 2.7 supports a few features, like dict comprehensions and OrderedDict, that 2.6 does not have).

The biggest wrinkle will be binaries: any code that relies on .so or .pyd modules probably won't work between intepreter versions. I usually end up having to pack version-specific binaries into the zip and extract them at startup time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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