Unable to have Shotgrid running in Maya 2023

Hi,

We are implementing Maya 2023 and unfortunately, we are unable to have a running ShotGrid integration.
Not a single error in our console or log files…

Everything is up to date: Core v0.20.12, tk-maya and all other apps, SG Desktop.
Everything is running fine in Maya 2020.4.

The switch between Python 2 to Python 3 for Nuke 11 to Nuke 13 was really smooth. So I don’t think it’s the issue here but who knows…

Any debug ideas?
Cheers

Have you turned on debug logging and looked at your tk-maya logs?

Thank you for your suggestion.

Yes, I did but not a single line is written when I launch Maya 2023.
This is exactly the same launcher with a version variable.

Maybe there’s a Maya ENV var you can set so Maya itself logs to a file?
Then you can see from there.

Yeah same issue here, very strange that there isn’t any error in the logs, even in the debug mode.

@Kevin_Lmr did you figure out why toolkit is not loading?

Yes, I’ve finally figured it out.

The issue was that our PYTHONPATH was reset between the launch from SG desktop and the actual software opening. During this period, we would lost the tk-maya path in the PYTHONPATH.

The best way to spot this was to observe the PYTHONPATH changes.

@Kevin_Lmr thanks for your response. yeah it does sounds like it’s related to the env variable. Would you please elaborate a bit more? Where did you reset the PYTHONPATH ? what did you have to set it to?

Appreciate your help in advance

In before_app_launch you can set environment variables but the documentation inside the is misleading.

It should prefer to use the prepend and append methods of sgtk.util so that you can’t accidentally destroy the environment variables needed for SG integration to launch inside the DCC.

https://developer.shotgridsoftware.com/tk-core/utils.html?highlight=appen#sgtk.util.append_path_to_env_var

Thanks @Ricardo_Musch, appreciate your suggestion, but still unclear what needs to be added to or remove from the PYTHONPATH? I think that’s the key not how to add it.

Both Maya 2020 and 2023 PYTHONPATH include path to the config core python location as well as the path to the tk-maya’s startup directory.

What’s the change you made to the PYTHONPATH that fixed the issue?

So it turns out there was a import issue in tk-maya userSetup.py that was causing the engine not to initialize. It was very unfortunate that we weren’t getting stacktrace, even via the debug mode.

But still interested to know the PYTHONPATH change you did.

Cheers

I mean that if you set the pythonpath in, for example, the before_app_launch hook you should not set it like this:

os.environ["PYTHONPATH"] = "foo"

but instead use:

sgtk.util.append_path_to_env_var("PYTHONPATH", "foo")

This is because Toolkit will already have set up the PYTHONPATH to ensure the engine starts.
If you overwrite the path you will destoy paths needed for the engine.

1 Like