Tk-maya : Cannot find procedure "MTsetToggleMenuItem"

I am currently installing SG Desktop on several workstations, using a modified config based on sgtk default2.

While I have absolutly no problem to launch any software on my own dev workstation, the other workstations won’t launch Maya 2019 through SG Desktop on a particular config, I get this error:

Cannot find procedure "MTsetToggleMenuItem".

Maya 2019 can launch if loading a sgtk default project config.
Maya crashs just before loading the full window, after the usual splash screen.

From Autodesk help, it seems the only way to debug this is to delete the local pref folder. This is not my case, as Maya 2019 launch without any problem when launching it without Shotgun Desktop.

It seems the problem comes from my custom sgtk config.
I’ve been trying for the past two hours to comment every modifications I made in default config 2 without breaking anything, but as there is absolutly no info about the “MTsetToggleMenuItem” this process is very long.

The very confusing thing is that:

  • I can load maya 2019 from SGDesktop on my workstation without any problem. On this pc, everything works as expected. Of course, everything is on the server.
  • Maya 2018 can be loaded from any workstation, but the Shotgun Menu only load on my workstation

Does anyone has more infos about Cannot find procedure "MTsetToggleMenuItem" ?

2 Likes

MTsetToggleMenuItem seems to be linked to the plugin modelingToolkit.mll. It is loaded by default on the workstations.

It seems something like a userSetup tries to call this function before the plugin is loaded.

I can’t find anything even remotely close to calling that in my config.

1 Like

Hi Ben – Are you modifying the PYTHONPATH at all in your config? Perhaps in the before_app_launch hook before launching Maya? It’s possible that you’re inadvertently removing something from the path, causing the error you’re seeing at Maya launch.

3 Likes

Hey Tannaz,

I do use this hook to set PYTHONPATH and SGTK_PREFERENCES_LOCATION to toolkit.ini.

I’ve been checking that my env var are the same between my dev workstation and the other workstations.

2 Likes

Hey Ben, please could you test on those affected workstations without your custom hook, so as to rule that out?
Cheers
Phil

2 Likes

As usual you were right:

Apparently, adding a python install to PTHONPATH will prevent Maya 2019 to find his Plugin Path.
I had several problems, as this hook ensured that C:\Python27 was set as PYTHONPATH, and we actually install the workstation with this PYTHONPATH.

I’ll rethink how I setup the workstations. Thanks for your help!

I’m not sure why Maya 2019 can’t wrk with this env var, do you have an idea?

2 Likes

In general Maya should work fine with the PYTHONPATH env var, it just depends what paths you add to that env var.
Appending a path to another python install folder, can be a bad idea when running in software with it’s own python interpreter.
The reason being is that, Maya may come shipped with a different python version, compiled differently. And if you include the another python interpreter path, then it may try and pick modules out of the other python interpreter rather than the one shipped with Maya. Also, you can it error as well when Python loads compiled code that was not compiled against the same compiler.

So I’m not entirely sure why you got that error exactly, but in general, it’s a bad idea to include another python interpreter’s paths when running in a different python interpreter.

I don’t know why exactly you are including that path, but usually people do it, if they have installed libraries in the local python interpreter that they would like to use.
The approach I’ve used in the past is to store the required libraries and custom python scripts in a folder on the server so they can be accessed outside of the python folder. I then sys.path.append to that location or set the PYTHONPATH to point to it. Though if any of those libraries contains compiled code, then you may run into an issue again.

2 Likes

Thanks for the clarification. I’ll try to dive deeper into this subject to avoid more problem in the futur.

2 Likes

My first problem is gone!

I’m trying to setup Philip’s solution (using a package directory), adding the package path to PYTHONPATH with before_app_launch.py:

1/ System has no PYTHONPATH env var at all
2/ Launch Maya through SGTK
3/ before_app_launch.py sets PYTHONPATH
4/ checking PYTHONPATH in cmd window : it’s ok
5/ checking PYTHONPATH window’s Env Var : it’s ok
6/ Checking PYTHONPATH in Maya (standalone, launched without SGTK): it’s ok
7/ Checking PYTHONPATH in Maya (launched with SGTK): NOP!

Why is PYTHONPATH modified when launching Maya through SGTK? How can I debug this?

Thanks

1 Like

Did you restart your machine or log in and out again? it’s possible Desktop isn’t picking up the changes in Windows.

2 Likes

That was it! Thanks a lot, my config is going to be way more clean.

2 Likes