Maya 2025 subprocess.Popen launches executable without DLLs ??

Hello,

I’m having a strange issue with Maya 2025 that I’m not having in any earlier Maya version, nor in a standalone Python 3.11 instance.

I’m trying to launch an executable that I made, from Maya using subprocess.Popen and what happens is it launches as it should, but in the executable my program adds additional path to PATH environment variable to load a module that has DLLs to load and my program can’t find those DLLs even after adding the paths successfully.
Again, this works correctly in all previous versions of Maya and it works correctly in a standalone Python 3.11 instance, but not in Maya 2025.

Is there something new in Maya that tempers with the executable’s environment or does it launch it in a sandbox environment, unlike previous versions of Maya?

Any clue to this issue would be greatly appreciated!
Thanks!

Which DLL’s?

That matters because Maya’s path will point to different folders, and it may find DLL’s named correctly but have the wrong version, or were compiled with the wrong compiler.
I’ve had this issue with both the Qt dll’s and the USD dll’s. And each library requires a different solution.

1 Like

Wow! you nailed it.
The dlls it failed to load for me are the USD dlls. I have a custom build of USD for my app.
What kind of solution did you find for that case?

Somebody made “fix” to USD on Anaonda in Windows. And instead of using the library loading mechanism that was already built into usd, they hard-coded adding extra variables to the PATH without cleaning up after themselves. :angry:
I put in a pull request to get it fixed (looks like 8 months ago). And they STILL haven’t merged

I don’t exactly remember how I fixed it locally. I think either patched the init file, or made a new wheel with the fixed init for our local pip server. I just remember it was hacky. But that’s not what I’d recommend you do unless you’re doing this in a studio environment.

I’d suggest you just sanitize your environment. ie. Make a copy of os.environ and remove the maya and usd stuff from envcopy['PATH'], then pass that environment copy to the env kwarg of subprocess.Popen. Also, I highly suggest looking at my issue and MR to get more context.

2 Likes

Cleaning the environment before passing it to subprocess did the trick.
Thank you so much for the clue! :grin:
It’s one of those things that you aren’t entirely sure how to approach it until someone tells what scope to look into, if that makes sense…
Thanks again!

1 Like