Toolkit Environment Variable


In a thread by @tannaz, she describes how to set environment variables using the core/hooks/ file. We do not currently have a, so the thread mentions copying the default file from the GitHub repo. Will this work with the tk-config-basic? If so, do we copy the file into the same core/hooks location of the basic config?

Also, when launching Toolkit there is a modification to the PYTHONPATH environment variable to include site-packages from the folder. When the Toolkit is closed, this path is then removed from the PYTHONPATH. I would like this same behavior where anything I add in the will also add to the PYTHONPATH and then remove itself once the Toolkit is closed. Will this happen by default by adding the variable in this way or do I also have to have a post cleanup process if I want to remove the path when closing Toolkit?



tk-core behaves the same regardless of the type of config you’re using. If you don’t have a core/hooks/ file in your config/ directory, that just means that you’re using the default copy of that core hook, with no customizations as of yet. You can just follow the instructions in the post you linked to.

As far as setting environment variables, you don’t need to worry about cleanup. Environment variables are scoped to the current environment. The changes you make to environment variables within a Toolkit process only apply within that process. The only time you’d have to do active cleanup or management is if there were potential clashes internal to your Toolkit process – for example, if you set an env var that you needed within Desktop that caused problems down the line in Maya, you’d need to manage that.

Hope that helps! Let us know if you have any other questions.


Thank you @tannaz!

I am running into an issue and was wondering if I could get some help? I am trying to do a pretty standard task, or so I would think, that will append to the PYTHONPATH a custom folder for Python modules. In trying to do so I am getting errors that PYTHONPATH does not exist, but in fact it does because I am able to print the os.environ["PYTHONPATH"] value in the Python console from within SG. I see the value is also set via TANK_CURRENT_PC. So, I changed my code from:

os.environ["PYTHONPATH"] = os_operator.join([UTILS_PATH, PYTHONPATH])


os.environ["PYTHONPATH"] = os_operator.join([UTILS_PATH, TANK_CURRENT_PC])

However, the error message I am getting is still finding the old code. I have deleted my ~/Library/Caches/Shotgun folder, and still getting this error:

Is there some other cache data that I need to remove to have it pull the latest version of the from my GitHub descriptor?

Also, when I uncomment line 34 the result of PYTHONPATH comes back as None?


Alright, it is working now. It must have just been a cooling off period because trying again 10 min later and the environment variable is being updated.



Glad you got it sorted! Sometimes I need a ten-minute cooling-off period, too. :blush:

Let us know if you have any other questions.