Maya's Python and Standalone's Python

872 views
Skip to first unread message

illunara

unread,
Sep 25, 2017, 4:04:05 AM9/25/17
to Python Programming for Autodesk Maya
Hi everybody
What's the difference of maya's Python ( Like mayapy as example) and standalone python(https://www.python.org)?
I tried to install Pip using mayapy and install other package as well, but nothing happend ( Which had been successed using standalone Python)
This is kind of vague, and i don't know where to start, anybody have knowledge about this?

It would be great if i can using mayapy to access other part of window's system without install standalone Python.
Thanks

Justin Israel

unread,
Sep 25, 2017, 4:11:31 AM9/25/17
to Python Programming for Autodesk Maya

On linux/osx mayapy is just a shell script that bootstraps the process to start Maya's bundled python interpreter. This is basically a normal Python, but they can control what version they provide and ship an internal site-packages with it.

On Windows, I don't remember if it's a bat or exe.

You should be able to use Maya's python interpreter from standalone shell scripts outside Maya. But it's usually better to install external libraries into an external PYTHONPATH, and then just add that path to Maya using Maya.env or userSetup.py

Justin


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/65c90116-31c9-4d56-9d8d-ee4052fbc933%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

illunara

unread,
Sep 25, 2017, 4:31:38 AM9/25/17
to Python Programming for Autodesk Maya
Hi Justin 

You should be able to use Maya's python interpreter from standalone shell scripts outside Maya. But it's usually better to install external libraries into an external PYTHONPATH, and then just add that path to Maya using Maya.env or userSetup.py


I don't understand what is the external PYTHONPATH mean? Would you give me an example how to do it please? I would like to add pyhook package (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook) so i can interact with window input system, Thanks

Justin Israel

unread,
Sep 25, 2017, 6:17:41 AM9/25/17
to Python Programming for Autodesk Maya
Here is some information about how the PYTHONPATH works and how to configure it on Windows :



Basically it can be any directory you want. The common default location is a scripts/ directory within your standard python system install. But you can designate any directory as long as it is on your PYTHONPATH. You can set that in your system variables or on the fly in your shell with virtualenv.

Here is information about setting custom PYTHONPATH locations for Maya :


Maya also has a scripts/ locations for you by default that acts a place to easy install modules. 

Does that help? 



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

illunara

unread,
Sep 25, 2017, 6:40:44 AM9/25/17
to Python Programming for Autodesk Maya
Hi Justin

This is getting confused, Python Standalone and Maya's Python has the same core (Python 2.7), with difference interpreter, right? So can we use mayapy to do whatever Standalone Python can do?
The reason is, i don't want to setup Standalone Python on user's machine, both their computers has maya's installed, so i think i can take advantage of it.


Thanks

Marcus Ottosson

unread,
Sep 25, 2017, 7:01:37 AM9/25/17
to python_in...@googlegroups.com

They are mostly the same, but you can’t run libraries compiled for one in the other, like PyQt.

Your pyhook may (I don’t know) be compiled, in which case you need to compile it for mayapy. For pure-Python libraries however, you can treat them the same.

To install pip for mayapy, simply run it with mayapy

$ mayapy get-pip.py
$ mayapy -m pip install pyhook

em.l...@gmail.com

unread,
Sep 25, 2017, 2:13:49 PM9/25/17
to Python Programming for Autodesk Maya
Hi Marcus
Wow, it works. If i run the setup from window cmd instead mayapy interpreter, everything work perfectly. Maybe this package require python shell to execute or something?

Anyway, Marcus and Justin. Made my day ;)

em.l...@gmail.com

unread,
Sep 25, 2017, 2:13:51 PM9/25/17
to Python Programming for Autodesk Maya
Thank Marcus
It works, how? i mean, when i tried to execfile(get-pip.py,var) from mayapy interpreter, nothing happend. And when i execute script from window shell, the script had been start O_O
Reply all
Reply to author
Forward
0 new messages