Pythonpath envt variable isn't registering

Hello,

Occasionally when I start up Maya (2018), it doesn’t recognize my pythonpath scripts. Restarting Maya always fixes the issue, but I just wondered if anyone else had the same problem, and if maybe there’s a fix to stop it ever happening?

Cheers,

Andy

How are you registering the environment variable? Is this from the Maya.env file?

I’ve added PYTHONPATH to my environment variables in advanced system settings (windows). That’s all, I think.

Weird.
If its set at the system level, I can’t think of a reason that Maya would somehow ignore the path.

Random question, what version of 2018 are you on?
Prior to 2018.1 there was a bug that caused the order of sys.path to be randomized, which could potentially cause import issues if there are naming conflicts between your scripts and others.

I’m on 2018.2 Guess I was hoping it was a common problem :slight_smile:

Its not something I’ve encountered myself.
Is it possible you’ve got some scripts at startup that might be removing paths? In the past I’ve included code to clear nonexistent paths from sys.path just so it wouldn’t be so cluttered, that happened to break once such that it wiped out almost all the paths.

When you do run into this, its probably best to check and see if the path is still in the environment, but not on sys.path

Something like:

import os
import sys
for path in os.environ.get('pythonpath', '').split(os.pathsep):
    if path not in sys.path:
        print(path)
1 Like