fubbu Posted September 26, 2019 Share Posted September 26, 2019 Can i open from houdini python shell a system python with all data from it. When i try open C:/Python27/python.exe from houdini python shell it always override system environment to houdini environment. And i also must say i cant add system python path because it always run houdini python library first and i always get an error, i try write PYTHONHOME and all environments from help https://www.sidefx.com/docs/houdini/ref/env.html, and nothing works.(Why i need that because i run external program by subprocces and it need system enviroment to run correctly) Could some help? Quote Link to comment Share on other sites More sharing options...
fubbu Posted September 26, 2019 Author Share Posted September 26, 2019 Ok i found one thing. When i run houdini all commands are runing from hython not python now question is the same how run command from python (even this python in orginal houdini folder "C:\Program Files\Side Effects Software\Houdini 17.5.258\python27") because script only dont work in hython. Quote Link to comment Share on other sites More sharing options...
LucaScheller Posted September 26, 2019 Share Posted September 26, 2019 (edited) Hi Daniel, Interesting question, I have never tried relinking the default python libs! The wiki says it's not possible on windows (See the picture below). Maybe you can get the original host env like described in this StackOverflow Post: https://stackoverflow.com/questions/23728250/start-new-subprocess-with-default-environment-variables import subprocess try: import _winreg as winreg except ImportError: try: import winreg except ImportError: winreg = None def env_keys(user=True): if user: root = winreg.HKEY_CURRENT_USER subkey = "Environment" else: root = winreg.HKEY_LOCAL_MACHINE subkey = r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment" return root, subkey def get_env(name, user=True): root, subkey = env_keys(user) key = winreg.OpenKey(root, subkey, 0, winreg.KEY_READ) try: value, _ = winreg.QueryValueEx(key, name) except WindowsError: return "" value = winreg.ExpandEnvironmentStrings(value) return value env_PATH = get_env("PATH", False) ### Check If ENV changes work subprocess.Popen(["echo" ,"%PATH%"],env={"PATH":str(env_PATH)},shell=True) ### Start File With Original ENV subprocess.Popen(["S:/python_2.7.5/python.exe" ,"S:/print_sys_path.py"],env={"PATH":str(env_PATH)},shell=True) Edited September 26, 2019 by LucaScheller Quote Link to comment Share on other sites More sharing options...
fubbu Posted September 27, 2019 Author Share Posted September 27, 2019 Thx Luca for answere but it didnt work it always run from hython. But now i try something else. When i run houdini shell(not python shell) and I run virtual enviroment (which i create before) and then run python everything is ok. Hython is overrided and my scripts work. Everything starts working like in regular python. Now i try write script that will by run this virtual enviroment and run my scripts. If it will succeed i post solve here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.