How to pass a .py script to hython?
2347
5
0
2023年7月19日 8:56
Hi guys,
I have a test .py module with a simple print line and I've been trying to run it in command line through hython.exe.
in hython I've tried: (though it's like writing "python '
somescript.py '" in python shell I assume, won't work, no?)
hython "C:/Users/<myusername>/Desktop/script_to_run_in_hython.py"
(invalid syntax on the last ")
in powershell:
"C:/Program Files/Side Effects Software/Houdini 19.5.569/bin/hython.exe" "C:/Users/TEMP.KATANA.000/Desktop/houdini_server/script_to_run_in_hython.py"
(UnexpectedToken error)
What's the right way to run a script from hython?
Edited by KatanaPoland - 2023年7月19日 09:20:17
graham
Member
1921 posts
Joined: 11月 2006
Offline
2023年7月20日 11:55
I think you'll need to provide an example of the file you're trying to run as Houdini on Windows seems to have no issues executing a passed in script for me.
Graham Thompson, Technical Artist @ Rockstar Games
lucap1
スタッフ
31 posts
Joined: 6月 2018
Offline
2023年7月20日 11:56
I usually define a function in my .py file and put the code I want to run in that function. Then I do the following: 1. Start hython 2. soure my_module 3. my_module.my_function() When I'm on Linux I use the shell. On windows I use cygwin for my shell. I've not tried this with the power shell
pelos
Member
621 posts
Joined: 8月 2008
Offline
2023年7月23日 14:41
you can put hython in path environment and call
hython
path_to_your_file.py
2023年9月6日 5:56
Thanks for your answers guys. I ended up running a .ps1 script from powershell that sets up venv, appends to python path and runs the actual .py script in which I do:
import os , sys
sys . path . append ( "C: \\ Program Files \\ Side Effects Software \\ Houdini 19.5.569 \\ houdini \\ python3.9libs" )
os . add_dll_directory ( "C: \\ Program Files \\ Side Effects Software \\ Houdini 19.5.569 \\ bin" )
import hou
Then I have access to the hou module no problem.