How to pass a .py script to hython?
2462
5
0
July 19, 2023 8:56 a.m.
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 - July 19, 2023 09:20:17
graham
Member
1922 posts
Joined: Nov. 2006
Offline
July 20, 2023 11:55 a.m.
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
Staff
31 posts
Joined: June 2018
Offline
July 20, 2023 11:56 a.m.
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
stevediaz
Member
3 posts
Joined: July 2023
Offline
July 21, 2023 1:40 a.m.
Hello
The right way to run a Python script from hython.exe in the command line is:
hython
path_to_your_script.py Make sure to replace
path_to_your_script.py with the actual path to your Python script.
pelos
Member
621 posts
Joined: Aug. 2008
Offline
July 23, 2023 2:41 p.m.
you can put hython in path environment and call
hython
path_to_your_file.py
Sept. 6, 2023 5:56 a.m.
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.