Once a variable from os.environ or sys.path has been changed is there any way to load the original values for os.environ or sys.path that the rest of the operating system sees. That is to say without restarting python.
I have an embedded version of python 2.7 that has custom values but I need to load the default system values.
Gimp image editor has a version of python 2.7 built in for running scripts. I am trying to use a subprocess inside of gimp's 2.7 python to launch python 3.6 to run some code. I am trying to do this because I would like to make a plugin that uses tensorflow on windows. Using neuralsytle/faststyle inside of gimp with a plugin gui would be great.
The problem is that gimp loads up custom values for path and pythonpath for the python 2.7 that is built into it. Those values are inherited by the subprocess I use to launch python 3.6.
>>> sys.path
['', 'C:\\Projects\\caffe\\python', 'C:\\Users\\audov\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip', 'C:\\Users\\audov\\AppData\\Local\\Programs\\Python\\Python36\\DLLs', 'C:\\Users\\audov\\AppData\\Local\\Programs\\Python\\Python36\\lib', 'C:\\Users\\audov\\AppData\\Local\\Programs\\Python\\Python36', 'C:\\Users\\audov\\AppData\\Roaming\\Python\\Python36\\site-packages', 'C:\\Users\\audov\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages']
Becomes
>>> sys.path
['', 'C:\\Program Files\\GIMP 2\\32\\lib\\gimp\\2.0\\python', 'C:\\Program Files\\GIMP 2\\lib\\gimp\\2.0\\plug-ins\\python-console', 'C:\\Program Files\\GIMP 2\\32\\lib\\python27.zip', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\plat-win32', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\lib-tk', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\lib-old', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\lib-dynload', 'C:\\building\\msys64\\mingw32', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\site-packages', 'C:\\Program Files\\GIMP 2\\32\\lib\\python2.7\\site-packages\\gtk-2.0']
How would I load up the standard values for those environment variables that the rest of the operating system sees.
import os, sys
os.environ
sys.path
Will display the original values for variable that have nothing to do with python. And then modified values for python and gimp.
Is there a way to load the unmodified environment values in a generic way.
I am running Windows 10.
I know I can append to the path or replace the path variable with values I copy beforehand. I could also have a string that I use to set env=foo on the subprocess.
But that is not a very good solution. I would like this to potentially work on other systems.
This is a hard question to look up the solution to because it is confused in search terms for finding out how to set the environment variables or read them normally.
EDIT Start new subprocess with 'default' environment variables
This question runs into the same problem and has a partial solution. As they put it "I'm not looking to pass an environment variable to a subprocess; I'm looking for the subprocess to return a default environment."
Unfortunately it is still not enough to get tensorflow to run in the new process. I will keep trying.