numpy, pylab, matplotlib inside of Maya

669 views
Skip to first unread message

Todd Widup

unread,
Mar 30, 2021, 7:32:36 PM3/30/21
to python_in...@googlegroups.com
what is the easiest way of getting them running correctly inside of Maya?  or even Pip for that matter?

thanks
-todd

--
Todd Widup
Creature TD / Technical Artist
todd....@gmail.com

Jakob Kousholt

unread,
Mar 30, 2021, 8:45:08 PM3/30/21
to python_inside_maya
Hey Todd,


(This will be for maya 2020, and on windows. Let me know if your system is different)

So to install pip in in maya you have to download the get-pip.py script from here:


The easiest way is to place that in your maya bin directory (Usually located at C:\Program Files\Autodesk\Maya2020\bin).
Then cd into that directory within a terminal and run the following command:

mayapy.exe get-pip.py

After that, you are now able to use pip to install any back you want using this command:
(from your bin directory)

mayapy -m pip install <Insert the name of the package you want pip to install>


One thing to note is that you don't have to install pip if you have maya 2022, as that ships with Python 3, which already contains pip!

Let me know if I need to clarify anything. Good luck!


--
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/CABBPk35j9gYLByhpBFnho6KXVUhhqO5EKmDuFG1TNSad2U8xgQ%40mail.gmail.com.

Marcus Ottosson

unread,
Mar 31, 2021, 9:04:15 AM3/31/21
to python_in...@googlegroups.com

Remember that anything installed via pip that was compiled, like numpy, was compiled for a specific version of Python; and it wasn’t the version of Python in Maya. Not even for Maya 2022.

Instead, you’d get the version coming off of PyPI, which is where pip gets its packages. Those have all been built for the vanilla Python off of python.org. So you should expect those libraries to either refuse to load outright (if you’re lucky), or to load and believe it got loaded into vanilla Python when really it’s Maya’s custom build. The result is either crashes, memory faults or worse; silent errors. Random errors that occur from bad memory being accessed but not always invalid. The kind that are next to impossible to debug.

If you do want numpy and other compiled things in Maya without worrying about that, if compile it for Maya (mayapy). There are semi-exceptions though; I used to use PyQt4 off of PyPI for Maya 2014-2015 for years without issue. Odds are the parts of Python used by that compiled library was identical across mayapy and python.org. But there’s no way (?) to know up-front!

For anything that isn’t compiled however - like six or black - this isn’t an issue and all of PyPI is at Maya’s disposal.

If you’d rather not take my word for it, Google about it or search this mailing list; it’s a topic that’s been rehashed a number of times over the years.

Stay safe!


Hannes Delbeke

unread,
Mar 31, 2021, 10:14:01 AM3/31/21
to Python Programming for Autodesk Maya
Adding to Marcus his point

installing from numpy wont work due to compile issues
however at a previous work place i asked the engineers to compile it for the maya specific version and this kept erroring out
the result: i never managed to get numpy working in maya

so if people online talk about "just use pip", they likely haven't tried it themselves.

a way to handle this might be run numpy outside of maya and set up a bridge between python in maya and python outside of maya

Jakob Kousholt

unread,
Mar 31, 2021, 10:38:10 AM3/31/21
to python_inside_maya
That's a fair point! I haven't used pip to install NumPy. I used pip to install a couple of other libraries which I've had no issues with, so I was unaware of the issues Marcus and Hannes are pointing to. 

Marcus Ottosson

unread,
Mar 31, 2021, 2:09:02 PM3/31/21
to python_in...@googlegroups.com

You can totally run NumPy in Maya, albeit compiling it is necessary and not easy. :S

Here’s someone doing it for 2018.

I doubt there’s anything you could build for Python that didn’t also build for Maya. As I understand it, the differences in Maya’s Python are additions to the source rather than removals. So if anything you’d be able to compile things with mayapy that you couldn’t compile with vanilla Python.


Todd Widup

unread,
Mar 31, 2021, 3:05:04 PM3/31/21
to python_in...@googlegroups.com
thanks all and yea, I was aware of the issue with Numpy..Ive seena  few ppl release version they have compiled for various version, just nothing for 2020 or 2022 yet

Juan Moraga

unread,
Mar 31, 2021, 3:36:04 PM3/31/21
to python_in...@googlegroups.com
You can see when a topic has bugged us too often when it gets so many replies in such a short period of time hahaha.
There are some nice people around that compile wheel files and shares them, I remember succeding instaling OTIO (or maybe it was OCIO or PIL, I can't remember now) with a wheel from a nice wheel database I found on the secret corners of the internet, because using the pip install wouldn't work for mayapy in Maya 2018 (or maybe I was doing sth wrong, who knows now). Also running py3 in a subprocess inside maya and capturing the output can do the work too, or having a server in python 3 that listens to a client in maya. but all these are more convoluted.
A friend of mine used conda to install certain libraries too.

This was my first 2 cents in this nice forum! I'm pleased to meet you guys ;)

David Alvarez

unread,
Mar 31, 2021, 4:32:12 PM3/31/21
to python_in...@googlegroups.com
I installed in the past the ones from this link https://drive.google.com/drive/folders/0BwsYd1k8t0lEMjBCa2N1Z25KZXc though never have the chance to give it much use. So I can grant you don't eventually get some unexpected errors. Anyway I hope that now with python 3.7 in maya 2022 we can use pip directly.


Justin Israel

unread,
Mar 31, 2021, 5:04:14 PM3/31/21
to python_in...@googlegroups.com


On Thu, Apr 1, 2021 at 8:36 AM Juan Moraga <juanmora...@gmail.com> wrote:
... Also running py3 in a subprocess inside maya and capturing the output can do the work too, or having a server in python 3 that listens to a client in maya. but all these are more convoluted.

I wasn't going to mention this new project I just started, until it was further along, but what you said here lines up with the purpose of the project:
https://github.com/justinfx/pygo-plugin

It is a port of hashicorp/go-plugin, but with Python as the host implementation. Allows you to write plugins in any language, with enhanced support if they are python (or Go) plugins. It turns the plugin into a gRPC server which is launched and managed as a child process within the host application. So you can do stuff like mixing py2 and py3, or use libraries with conflicting dependencies such as those that were not compiled for the host application. Or you can use plugins written in other languages.  
The project is still alpha since I only finished the proof-of-concept and working examples. Basic implementation works so far but needs tests, docs, features, ... 
 

Marcus Ottosson

unread,
Apr 1, 2021, 2:07:34 AM4/1/21
to python_in...@googlegroups.com

Allows you to write plugins in any language

I tried grokking that README and the README of the parent project, but can’t figure out what “plugin” means in this context? :S I think you need an example or usecase. Do you mean a C-extension? Or a Python module? Or some plug-in to the Python intepreter, like additional syntax? Getting off-topic, sorry haha. But if you mean a method of communicating between processes, then “plugin” doesn’t seem the right choice of word. That’s just an IPC library.


Justin Israel

unread,
Apr 1, 2021, 5:51:06 AM4/1/21
to python_in...@googlegroups.com


On Thu, 1 Apr 2021, 7:07 pm Marcus Ottosson, <konstr...@gmail.com> wrote:

Allows you to write plugins in any language

I tried grokking that README and the README of the parent project, but can’t figure out what “plugin” means in this context? :S I think you need an example or usecase. Do you mean a C-extension? Or a Python module? Or some plug-in to the Python intepreter, like additional syntax? Getting off-topic, sorry haha. But if you mean a method of communicating between processes, then “plugin” doesn’t seem the right choice of word. That’s just an IPC library.


I will try not to hijack this thread too much. But did you check out the example? 


"plugin" implements some grpc api spec and acts as a server. 
"client" is the host that defines the API spec for plugins and loads them as a child process. The plugin keeps running as a server and makes the plugin api available via grpc. So it is a plugin because it implements some defined number of functions and is loaded by the host. It just so happens that the communication layer is grpc as opposed to a native python import or a dlopen. 
In the parent project one can write plugins in any language to be loaded into a Go host app. So I implemented the host (client) for python. 
Happy to chat about this on another thread (or here if it still feels relevant)


Reply all
Reply to author
Forward
0 new messages