Getting Maya Python API 2.0 to work correctly in PyCharm 2017

Anyone been able to get PyCharm 2017 to recognize Maya Python API 2.0 with proper introspection? Importing to the protected member works:

import maya.api._OpenMaya_py2 as apiOM

but

import maya.api.OpenMaya as apiOM

doesn’t - it’ll throw unexpected argument warnings on parsed values for things like MMatrix.

I’m doing the standard setup using the devkit for code completion.

this link shows you how:
https://forums.autodesk.com/t5/maya-programming/maya-python-api-2-0-ide-code-complete/td-p/6239681

Abbreviated version:

  1. Get the devkit.
  2. Link pymel completions to your interpreter in PyCharm.
  3. Remove the \Maya201X\Python\Lib\site-packages path from the interpreter in the same window.

I just did these steps from scratch and they worked fine!

1 Like

Yep - exactly what I’ve got here. Most things complete correctly cmds, mel etc… just no go with the api 2.0.

FWIW this is my setup and I’ve got full completion… Maybe try invalidating your caches and restarting?

I get similar argument warnings. It’s not something I like getting used to, but I’ve dealt with. If anyone knows a fix, I’d also like to know.

@leocov - this appears to be less about auto-complete, as that does work when importing the API module. Introspection seems to be the annoyance after it’s imported.

\devkit\other\pymel\extras\completion\py\maya\api\OpenMaya.py file content must be:
from _OpenMaya_py2 import *

Then you can use:
import maya.api.OpenMaya as om

Follow the same way for the other files.

Importing everything isn’t the best idea as well as protected members (not valid PEP8).

Also isn’t _OpenMaya_py2 just the stubs?