Hello,
I would like to ask about the current state of PySide in Houdini 20.5 with Python 3.11. If I understand correctly, the new VFX Reference Platform expects an updated PySide/Qt version, but vanilla Python 3.11.7 does not support PySide2. Since I work in a virtual environment and perform tasks outside of Houdini using VSCode, I can’t easily replicate my environment using traditional pip. Consequently, many of my tests are not functional and of course IDE screem and wont provide code support.
I’ve read the documentation, but there is very little information available regarding this issue. Could you please clarify the current state? Why does Houdini with Python 3.11 support PySide2, and what can we expect in the future? Will PySide6 be part of the solution?
Thank you in advance!
Lukas
Houdini 20.5-python3.11 pyside2 support question
1614 4 5- Lukas Chovanec
- Member
- 16 posts
- Joined: June 2018
- Offline
- rvinluan
- Staff
- 1274 posts
- Joined: July 2005
- Offline
Hi Lukas,
You are correct. The VFX Reference Platform calls for Qt6/PySide6 and Python 3.11 this year but unfortunately, we were not able to accommodate Qt6/PySide6 support in time for the Houdini 20.5 gold release. The Houdini 20.5 development cycle was shorter than usual and we were concerned about stability if we rushed the Qt6/PySide6 port in order to make it for release day.
The plan, however, is to release Qt6/PySide6 support later this year in a production build update. We are actively working on support and squashing bugs.
You can check out this help page, which tracks Qt/PySide versions as well as adherence to the VFX Reference Platform:
https://www.sidefx.com/docs/houdini/licenses/ [www.sidefx.com]
As for PySide2, if you are unable to use
On Windows, you need to also add this bit of code at the beginning of your Python script before importing PySide2:
The call above is needed so that Houdini's PySide2 modules can locate the Qt5 .dll libraries that are in the Houdini distro. Note that the code above assumes that you have %HFS% set in your environment. If not, then you can instead hard-code the HFS path instead of calling
Cheers,
Rob
You are correct. The VFX Reference Platform calls for Qt6/PySide6 and Python 3.11 this year but unfortunately, we were not able to accommodate Qt6/PySide6 support in time for the Houdini 20.5 gold release. The Houdini 20.5 development cycle was shorter than usual and we were concerned about stability if we rushed the Qt6/PySide6 port in order to make it for release day.
The plan, however, is to release Qt6/PySide6 support later this year in a production build update. We are actively working on support and squashing bugs.
You can check out this help page, which tracks Qt/PySide versions as well as adherence to the VFX Reference Platform:
https://www.sidefx.com/docs/houdini/licenses/ [www.sidefx.com]
As for PySide2, if you are unable to use
pip
to setup your venv, then you can try having your venv use Houdini's PySide2 packages by setting the PYTHONPATH
environment variable. For example:- on Linux,
export PYTHONPATH=$HFS/python/lib/python3.11/site-packages-forced
- on macOS,
export PYTHONPATH=$HFS/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages-forced
- on Windows,
set PYTHONPATH=%HFS%/python311/Lib/site-packages-forced
On Windows, you need to also add this bit of code at the beginning of your Python script before importing PySide2:
import os os.add_dll_directory("{}/bin".format(os.environ["HFS"]) from PySide2 import QtCore, QtGui, QtWidgets
The call above is needed so that Houdini's PySide2 modules can locate the Qt5 .dll libraries that are in the Houdini distro. Note that the code above assumes that you have %HFS% set in your environment. If not, then you can instead hard-code the HFS path instead of calling
os.environ["HFS"]
Cheers,
Rob
- Lukas Chovanec
- Member
- 16 posts
- Joined: June 2018
- Offline
Thanks for the very thorough explanation and info on the current state of things.
I tried to use your suggestion and add DLL libs. For unittest, I am already using the HFS variable, so it fits into my workflow. The problem is, it seem to produce another issue.
Error is:
here is code i use to test :
I double-checked paths to be sure there is not issue, but I still can't make it run outside of Houdini. Could be my mistake but ddl do work (removing it produces a different error right on import). It won't run QApplication tho. So far, i feel it would be best to go for Python 3.10 version of Houdini 20.5 to avoid all that hassle, which may go away once Houdini supports PySide6.
I tried to use your suggestion and add DLL libs. For unittest, I am already using the HFS variable, so it fits into my workflow. The problem is, it seem to produce another issue.
Error is:
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
here is code i use to test :
import os import sys # Ensure the DLL directory is added os.add_dll_directory("{}/bin".format(os.environ["HFS"])) from PySide2 import QtWidgets from PySide2 import QtCore from PySide2.QtWidgets import QApplication class FontDemo(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) hbox = QtWidgets.QHBoxLayout() self.setGeometry(500, 300, 250, 110) self.setWindowTitle('Font Demo') button = QtWidgets.QPushButton('Change Font', self) button.setFocusPolicy(QtCore.Qt.NoFocus) button.move(20, 20) hbox.addWidget(button) self.connect(button, QtCore.SIGNAL('clicked()'), self.showDialog) self.label = QtWidgets.QLabel('This is some sample text', self) self.label.move(130, 20) hbox.addWidget(self.label, 1) self.setLayout(hbox) def showDialog(self): ok, font = QtWidgets.QFontDialog.getFont() if ok: self.label.setFont(font) # Create an instance of QApplication app = QApplication(sys.argv) # Create an instance of your main widget dialog = FontDemo() # Show the main widget dialog.show() # Enter the main event loop app.exec_()
I double-checked paths to be sure there is not issue, but I still can't make it run outside of Houdini. Could be my mistake but ddl do work (removing it produces a different error right on import). It won't run QApplication tho. So far, i feel it would be best to go for Python 3.10 version of Houdini 20.5 to avoid all that hassle, which may go away once Houdini supports PySide6.
Senior Technical Artist at Cloud Imperium Games
- rvinluan
- Staff
- 1274 posts
- Joined: July 2005
- Offline
Are you by any chance running your code from a regular Python interpreter instead of from Houdini/hython?
If that's the case, then you need to tell PySide/Qt where the Qt plugins are located on disk since Houdini ships the Qt plugins in a non-standard location. To do that, you can either set
Cheers,
Rob
If that's the case, then you need to tell PySide/Qt where the Qt plugins are located on disk since Houdini ships the Qt plugins in a non-standard location. To do that, you can either set
QT_PLUGIN_PATH=%HFS%/bin/Qt_plugins
in the environment or add this bit of code before you create the QApplication:QApplication.setLibraryPaths(["{}/bin/Qt_plugins".format(os.environ["HFS"])])
Cheers,
Rob
- mingmekka
- Member
- 2 posts
- Joined: April 2023
- Offline
Hello, thanks a lot for the provided information, that helps a lot.
I have another question regarding code completion in this case. I get code completion for "hou" but I can't get it work for PySide2 modules like QtCore or QtWidgets in VSCode.
Here is my code for testing and the settings.json:
//settings.json
"python.defaultInterpreterPath": "C:\\Program Files\\Side Effects Software\\Houdini 20.5.278\\bin\\hython.exe",
"python.autoComplete.extraPaths": [
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/shiboken2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/PySide2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/python3.11libs"
],
"python.analysis.extraPaths": [
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/shiboken2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/PySide2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/python3.11libs"
]
Thanks a lot and best regards
I have another question regarding code completion in this case. I get code completion for "hou" but I can't get it work for PySide2 modules like QtCore or QtWidgets in VSCode.
Here is my code for testing and the settings.json:
import hou import os import sys ## Tried all of this also #os.add_dll_directory("{}/bin".format(os.environ["HFS"])) #from PySide2 import QtCore, QtGui, QtWidgets #pyside2_path = os.path.join(os.environ["HFS"], "python3.11", "lib", "site-packages-forced") #sys.path.append(pyside2_path) #Set the path to PySide2 manually if necessary #pyside2_path = "C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/PySide2" #sys.path.append(pyside2_path) # Set DLL path for PySide2 #os.add_dll_directory("{}/bin".format(os.environ["HFS"])) from PySide2 import QtCore, QtGui, QtWidgets def getHoudiniMainWindow(): return hou.qt.mainWindow() class Live_renamer(QtWidgets.QDialog): def __init__(self, parent=getHoudiniMainWindow()): super(Live_renamer, self).__init__(hou.qt.mainWindow()) self.configure_dialog() def configure_dialog(self): self.setWindowTitle("Live node renamer") self.setMinimumWidth(480) self.setMinimumHeight(340)
//settings.json
"python.defaultInterpreterPath": "C:\\Program Files\\Side Effects Software\\Houdini 20.5.278\\bin\\hython.exe",
"python.autoComplete.extraPaths": [
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/shiboken2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/PySide2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/python3.11libs"
],
"python.analysis.extraPaths": [
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/shiboken2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced/PySide2",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages",
"C:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/python3.11libs"
]
Thanks a lot and best regards
Edited by mingmekka - Sept. 5, 2024 08:31:51
-
- Quick Links