For context, I am trying to run code that tries to read an environment variable and spits an error:
_PySpin.SpinnakerException: Spinnaker: System instance cannot be acquired. Could not load producer. Make sure that the environment variable FLIR_GENTL64_CTI_VS140 exists, and points to the location of the file FLIR_GenTL_v140.cti [-1012]
So, after much digging, I found where the file is and went into windows system Properties -> Advanced -> Environment Variables, and to my surprise, there is a variable FLIR_GENTL64_CTI_VS140
and sure enough it points to the appropriate file.
In python, if I import os and run os.environ, the following is printed:
environ({'ALLUSERSPROFILE': 'C:\\ProgramData', 'APPDATA': 'C:\\Users\\Kingdel\\AppData\\Roaming', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files', 'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'KINGDEL', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'CONDA_DEFAULT_ENV': 'PointLock_pyspin', 'CONDA_PREFIX': 'C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin', 'CONDA_PROMPT_MODIFIER': '(PointLock_pyspin) ', 'CONDA_SHLVL': '1', 'DRIVERDATA': 'C:\\Windows\\System32\\Drivers\\DriverData', 'FC2PATH': 'C:\\Program Files\\Point Grey Research\\FlyCapture2\\bin64', 'FPS_BROWSER_APP_PROFILE_STRING': 'Internet Explorer', 'FPS_BROWSER_USER_PROFILE_STRING': 'Default', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Users\\Kingdel', 'IDEA_INITIAL_DIRECTORY': 'C:\\Users\\Kingdel\\Desktop', 'LOCALAPPDATA': 'C:\\Users\\Kingdel\\AppData\\Local', 'LOGONSERVER': '\\\\KINGDEL', 'NIEXTCCOMPILERSUPP': 'C:\\Program Files (x86)\\National Instruments\\Shared\\ExternalCompilerSupport\\C\\', 'NUMBER_OF_PROCESSORS': '4', 'ONEDRIVE': 'C:\\Users\\Kingdel\\OneDrive', 'OS': 'Windows_NT', 'PATH': 'C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin;C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin\\Library\\mingw-w64\\bin;C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin\\Library\\usr\\bin;C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin\\Library\\bin;C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin\\Scripts;C:\\ProgramData\\Anaconda3\\envs\\PointLock_pyspin\\bin;C:\\ProgramData\\Anaconda3\\condabin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0;C:\\WINDOWS\\System32\\OpenSSH;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\Program Files\\MATLAB\\R2012b\\runtime\\win64;C:\\Program Files\\MATLAB\\R2012b\\bin;C:\\Program Files\\Microsoft Windows Performance Toolkit;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Point Grey Research\\FlyCapture2\\bin64;C:\\Program Files\\Point Grey Research\\FlyCapture2\\bin64\\vs2013;C:\\Program Files\\Point Grey Research\\FlyCapture2\\bin64\\vs2015;C:\\Users\\Kingdel\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Kingdel\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\Kingdel\\AppData\\Local\\Microsoft\\WindowsApps;.', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel', 'PROCESSOR_LEVEL': '6', 'PROCESSOR_REVISION': '3a09', 'PROGRAMDATA': 'C:\\ProgramData', 'PROGRAMFILES': 'C:\\Program Files', 'PROGRAMFILES(X86)': 'C:\\Program Files (x86)', 'PROGRAMW6432': 'C:\\Program Files', 'PROMPT': '(PointLock_pyspin) $P$G', 'PSMODULEPATH': 'C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules', 'PUBLIC': 'C:\\Users\\Public', 'PYCHARM_HOSTED': '1', 'PYTHONIOENCODING': 'UTF-8', 'PYTHONPATH': 'C:\\Users\\Kingdel\\Documents\\GitHub\\spinnaker_python', 'PYTHONUNBUFFERED': '1', 'SESSIONNAME': 'Console', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\\Users\\Kingdel\\AppData\\Local\\Temp', 'TMP': 'C:\\Users\\Kingdel\\AppData\\Local\\Temp', 'USERDOMAIN': 'KINGDEL', 'USERDOMAIN_ROAMINGPROFILE': 'KINGDEL', 'USERNAME': 'Kingdel', 'USERPROFILE': 'C:\\Users\\Kingdel', 'VS100COMNTOOLS': 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Tools\\', 'VXIPNPPATH': 'C:\\Program Files (x86)\\IVI Foundation\\VISA\\', 'VXIPNPPATH64': 'C:\\Program Files\\IVI Foundation\\VISA\\', 'WINDIR': 'C:\\WINDOWS'})
Anyway, the point is that it is a different set of variables than I see in windows system Properties -> Advanced -> Environment Variables:
Also, what os.environ prints does not seem to be the User variables for the my current user either.
Anyway, my primary question is, of course, how do I get FLIR_GENTL64_CTI_VS140
to show up as an environment variable in my python, given that it is an environment variable, at least on my system?
I suspect that the answer has something to do with python os.environ['USERNAME']
being 'Kingdel', while the environment variables listed under windows system Properties -> Advanced -> Environment Variables is 'SYSTEM'
. This is probably because python is installed on the user Kindel instead of above any user. But, I am hoping for a solution that does not require reinstalling python. Is there a os.change_user type of command or something? Or maybe I can clone over environment variables from my system to the appropriate user somehow or something like that?
Thank you!
I tried uninstalling the SDK (and it's associated programs) that I am trying to use and to reinstall it on my user rather than directly on C drive, thinking that might automatically create the correct variables on my user, but it turns out that I cannot install the program within the user directory (maybe that is a windows thing as I am primarily a Mac user).
I tried to find a way to change user with python using os.setuid(), but the solution I found for doing that used pwd package, but this is being done on windows; so, I could not do that and did not find a work around.