Integrating Pycharm with houdini tutorial?

   3529   10   4
User Avatar
Member
41 posts
Joined: May 2021
Offline
Well my hda script is getting larger and larger, and my eyesight is weaker and weaker, plus getting "in" and "out" for testing in the scene becomes really tiresome, stretching the window on hda script tab is really out of fashion (tear-able window would be so nice) so how do you integrate Pycharm? I have the latest (free) version 2021.2, Houdini 17.5.391, and Houdini python support archive (hyton interpreter I guess), what's next? Do I need something more? I did my share of digging on internet but all topics on different forums are at least five years old and with dozens of "solutions" who scare the pants off me... I tried to integrate Sublime Text 3 but after poking the houdini environment file Houdini froze on startup... no thank you...
User Avatar
Member
782 posts
Joined: Feb. 2016
Offline
Hello Krieg,
Few months ago I submitted a feature request to improve the UI of the Type Properties Window. Feel free to add your name to ID#112807

Requests:
A) the Create Parameters area in the Parameters section should be collapsible.
B) A floating TAB Menu to add new parameters could serve very well, like the TAB Menu for operators in the network view.
C) In the Scripts sections, the scripts area on the left should be collapsible as well.


Point C) should help to have a larger area for coding in the hda script tab.


cheers
Edited by Andr - Aug. 12, 2021 14:11:43
User Avatar
Member
41 posts
Joined: May 2021
Offline
After a LOT of mumbo-jumbo with visual code studio I managed it to integrate with Houdini... Jesus Christ man... first download houdini plug-in((!!!) WHY THE F***K do we need a plug-in for this??!!?!) then assign VCS as external text editor, then choose houdini's version of python as interpreter, then write some MORE code in VCS to set path variables (which I didn't remember because I don't care) so you could have full integration i.e. import hou module and auto suggestion... and then FINALLY after more setting of color themes and size of fonts I can have full screen, medium font size solution with a good dark (i.e. black) background so I don't cry my eyes out...

Sorry for the language... but couldn't SideFX integrate some of these solutions with Houdini by default? At least ones who are free after all? Did I mention that I have tried to integrate SublimeText, Pycharm and one more who I didn't remember... they did not work either... and lack of instructions or tutorials is abysmal... few years old... different versions etc. etc.
Edited by kriegmesser74 - Aug. 13, 2021 13:31:21
User Avatar
Member
6 posts
Joined: Oct. 2016
Online
I agree Krieg. We can't write good, robust python code without at least one good IDE supported and documented for setup. I'm working in Pycharm and I never got it to autocomplete. can't seem to get any sort of hou module from the hython or python installs in houdini. No idea where to look at this point.
User Avatar
Member
7 posts
Joined: Feb. 2017
Offline
Here is how I got the PyCharm integration working, including autocomplete:

  1. Go to your Python Interpreter settings (in the bottom right, or File>Settings>Project>Python Interpreter).
  2. Click the gear icon in the upper right corner to show all your interpreters.
  3. In the top left corner of the new window, click the "+" button to add a new interpreter.
  4. Pick the System Interpreter and then browse to the path of your Houdini installation that has the Python executable that you want to use (2.7 vs 3.7 for example). The path probably looks something like this: C:\Program Files\Side Effects Software\Houdini 18.x.xxx\python27\python2.7.exe.
  5. After you've pressed OK in the window, you will go back to the window with the list of interpreters. Select your new interpreter and click the 5th button from the top left to "Show paths for the selected interpreter".
  6. By default it should have some paths to libraries already. However, the specific hython libs are probably not in the list, so you need to add that by pressing the "+" in the top left corner. The path should look something like this: C:\Program Files\Side Effects Software\Houdini 18.x.xxx\houdini\python2.7libs (or 3.7libs if you want to use 3.7). These libs will give you the autocomplete functionality for the HOM classes.
  7. Last but not least, for each Houdini Python project you need to set the interpreter to this new interpreter. And in order to get the autocomplete working properly, you need to import the hou module at the start of each file where you want to use it. It is as simple as import hou, and PyCharm should recognize the module from the interpreter.

From there on, you can use the hou module the same way you would inside Houdini, for example:
import hou
hou.node("../..")
or
hou.pwd().geometry()

I hope this helps! I couldn't attach pictures because that would be quite a few pictures, so I hope that my instructions are clear enough to follow. If you need any further help, feel free to reach out to me.
Technical Animator (using KineFX) at Enliven | Social Enterprise
idsboonstra.artstation.com
User Avatar
Member
83 posts
Joined: Oct. 2020
Offline
followed the steps to the letter, still no autocompletion
https://www.youtube.com/channel/UC4NQi8wpYUbR9wLolfHrZVA [www.youtube.com]
User Avatar
Member
291 posts
Joined: Aug. 2019
Offline
    "python.autoComplete.extraPaths": [
"C:\\Program Files\\Side Effects Software\\Houdini 19.0.455\\houdini\\python3.7libs",
],
"python.analysis.extraPaths": [
"C:\\Program Files\\Side Effects Software\\Houdini 19.0.455\\houdini\\python3.7libs",
],

This is how to setup autocompletion for VScode. If you put your Python code in a package, just add them as well.

Note that VSCode doesn't do type inference, and SideFx hasn't written any type annotation in their Python. So the autocompletion is rather limited.
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
hou works but Autocomplete is what is needed.
Not working....
User Avatar
Member
83 posts
Joined: Oct. 2020
Offline
Ids
Here is how I got the PyCharm integration working, including autocomplete:

  1. Go to your Python Interpreter settings (in the bottom right, or File>Settings>Project>Python Interpreter).
  2. Click the gear icon in the upper right corner to show all your interpreters.
  3. In the top left corner of the new window, click the "+" button to add a new interpreter.
  4. Pick the System Interpreter and then browse to the path of your Houdini installation that has the Python executable that you want to use (2.7 vs 3.7 for example). The path probably looks something like this: C:\Program Files\Side Effects Software\Houdini 18.x.xxx\python27\python2.7.exe.
  5. After you've pressed OK in the window, you will go back to the window with the list of interpreters. Select your new interpreter and click the 5th button from the top left to "Show paths for the selected interpreter".
  6. By default it should have some paths to libraries already. However, the specific hython libs are probably not in the list, so you need to add that by pressing the "+" in the top left corner. The path should look something like this: C:\Program Files\Side Effects Software\Houdini 18.x.xxx\houdini\python2.7libs (or 3.7libs if you want to use 3.7). These libs will give you the autocomplete functionality for the HOM classes.
  7. Last but not least, for each Houdini Python project you need to set the interpreter to this new interpreter. And in order to get the autocomplete working properly, you need to import the hou module at the start of each file where you want to use it. It is as simple as import hou, and PyCharm should recognize the module from the interpreter.

From there on, you can use the hou module the same way you would inside Houdini, for example:
import hou
hou.node("../..")
or
hou.pwd().geometry()

I hope this helps! I couldn't attach pictures because that would be quite a few pictures, so I hope that my instructions are clear enough to follow. If you need any further help, feel free to reach out to me.


I keep getting this error

Attachments:
Screenshot_1.png (43.6 KB)

https://www.youtube.com/channel/UC4NQi8wpYUbR9wLolfHrZVA [www.youtube.com]
User Avatar
Member
93 posts
Joined: April 2011
Offline
Hi AhmedHindy
I had the same issue. If you are using python3.7 or more recent in Windows, it's more likely because of the way python loads dll. Before 3.7, adding the $HFS/bin folder to the path was good., but the path variable is not used anymore. Instead, you must use this:
import os
os.add_dll_directory("houdini_install/bin")
import hou

Here is the explaination:
python load dll failed [bugs.python.org]
User Avatar
Member
160 posts
Joined: Oct. 2016
Offline
If you edit externally, will you get the built in help to work in your external editor? (see image)

Attachments:
Screenshot_2022-09-25_21-36-47.png (78.6 KB)

Full time IT-teacher (8y) / junior TD / Debian11 XFCE / Zbrush (Wine) / Python / VNC / networks / two small kids / BSc CS:CG / Stockholm
  • Quick Links