PyQt4 inside Houdini

   12867   23   1
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
I am running H12 in ubuntu 11.10 where python 2.7, 2.6 and 2.5 is installed, default is 2.7. PyQt4 is also installed. When I am importing PyQt4 module from a normal python shell, everything is ok. When I do the same from inside houdini or from hython, I get No module named PyQt4.

Why is this happening?

Thanks in advance.
User Avatar
Member
3 posts
Joined: Feb. 2010
Offline
Hello. You must be a Bournemouth student judging by the name.

It appears the python-qt4 Debian package does not support Python 2.5 anymore in Ubuntu 11.10.

If this is caused by Houdini using Python 2.5 it maybe possible to change the Python version by following the instructions here:

http://www.sidefx.com/docs/houdini12.0/news/11/python [sidefx.com]
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
ihenderson
Hello. You must be a Bournemouth student judging by the name.

It appears the python-qt4 Debian package does not support Python 2.5 anymore in Ubuntu 11.10.

If this is caused by Houdini using Python 2.5 it maybe possible to change the Python version by following the instructions here:

http://www.sidefx.com/docs/houdini12.0/news/11/python [sidefx.com]

Well you are right about the Bournemouth

when I am loading hython (because for some reason import hou in standard python shell does not work for me) it says that Python 2.6.4 is loadedand not 2.5. Also when I running sys.path inside there I get paths only from inside houdini/python installation directory, it seems that houdini uses its own python installations.



even though python2.6 was installed before houdini. How can I make hython load also standard python's modules? Made what I am says it totaly wrong, it drives me crazy that I cant fix it.
User Avatar
Member
224 posts
Joined: Nov. 2008
Offline
Hython uses it's own Python Iterpreter, under windows. I don't know what you are using but in Windows, all the modules referenced are bundled with the houdini hython version. Houdini 11 Python was compiled using visual studio 2005, therefore not working with most default python 3rd party libs. Houdini 12 was compiled using visual studio 2008.

If you're running linux, starting hython starts the houdini python env. If you want to import the HOU module in a default python session (say 6.4) you should be able to do that, if all the other houdini variables are set up correct (sourced):http://www.sidefx.com/docs/houdini12.0/hom/commandline [sidefx.com]

In Hython you would need to point the hython interpreter to the location of your Qt folder. Append the -QtPackage- path to the python path (sys.path.append(“/qtpackage”))

I managed to get pyQt4 running, importing the hou package to control and work with Houdini. This was under windows. You might have to compile you're own Qt version bit I doubt it.
Senior Technical Artist Guerrilla Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
cklosters
Hython uses it's own Python Iterpreter, under windows. I don't know what you are using but in Windows, all the modules referenced are bundled with the houdini hython version. Houdini 11 Python was compiled using visual studio 2005, therefore not working with most default python 3rd party libs. Houdini 12 was compiled using visual studio 2008.

If you're running linux, starting hython starts the houdini python env. If you want to import the HOU module in a default python session (say 6.4) you should be able to import the HOU module, if all the other houdini variables are set up correct (sourced):http://www.sidefx.com/docs/houdini12.0/hom/commandline [sidefx.com]

I managed to get pyQt4 running, importing the hou module if necessary. This was under windows. You might have to compile you're own Qt version that works with the hou package.

thaks for the reply, well I am on linux and I am using H12. I cant get import hou in standard python that's why I am using hython which imported hou by default.

Well, I have check everything realited to this in the documentation, included the link you posted, but nothing works. I think somewhere in the forums I found that its not possible to import hou in stadard python, I think it was for mac, maybe its the same linux. But either way, when you are inside houdini and you want to use pyqt with python code, as in this tutorial: http://www.sidefx.com/docs/houdini12.0/hom/cookbook/pyqt/part1/ [sidefx.com] importing hou is not the problem because is already imported but trying to import pyqt4 gives the same error: No module named PyQt4.
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
cklosters
In Hython you would need to point the hython interpreter to the location of your Qt folder. Append the -QtPackage- path to the python path (sys.path.append(“/qtpackage”)).

to the location of qt or pyqt4?
User Avatar
Member
224 posts
Joined: Nov. 2008
Offline
i9089303
cklosters
In Hython you would need to point the hython interpreter to the location of your Qt folder. Append the -QtPackage- path to the python path (sys.path.append(“/qtpackage”)).

to the location of qt or pyqt4?

PyQt4. And you should be able to import the hou module in a default python shell if the environment is set up correctly.

On Mac OS X and Linux, Houdini uses the system’s Python. On Windows, it uses the version of Python installed with Houdini.

On Linux, Houdini does not look at $PATH when trying to search and load the Python library. Instead it searches all the paths in $LD_LIBRARY_PATH, then /lib and then /usr/lib. If it can’t find a suitable Python library in the system, then it defaults to the one in $HFS. If your Python library is not in a standard location, you should add its directory path to $LD_LIBRARY_PATH.
Senior Technical Artist Guerrilla Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
cklosters
On Mac OS X and Linux, Houdini uses the system’s Python. On Windows, it uses the version of Python installed with Houdini.

well I am on linux and for some reason houdini uses the python installed with houdini. I can see that when I enter sys,path in hython and I get:



I have uninstalled houdini, and everything else is installed already, python2.6 and pyqt. I will try to install H12 again and see what python will choose to use. Then I will try to append the -PyQt4- path to the python path (sys.path.append(“/qtpackage”)) as you said and I will be back soon with results.
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
On Linux, Houdini will try to use your system version if possible. Houdini only supports 2.5/2.6, defaulting to the 2.6 if available. If it cannot find one of those I believe it will use its internal version. You'll need to see what version your Houdini is running and install PyQt for that build, unless it's using the internal version. The easiest way to check is to just launch Houdini/hython and import something standard and see its path.
import os
>>> os
<module ‘os’ from ‘/usr/lib/python2.6/os.pyc’>

Since I'm using the system's 2.6, I just need to have PyQt installed for that version and I can import it just fine.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
graham
On Linux, Houdini will try to use your system version if possible. Houdini only supports 2.5/2.6, defaulting to the 2.6 if available. If it cannot find one of those I believe it will use its internal version. You'll need to see what version your Houdini is running and install PyQt for that build, unless it's using the internal version. The easiest way to check is to just launch Houdini/hython and import something standard and see its path.
import os
>>> os
<module ‘os’ from ‘/usr/lib/python2.6/os.pyc’>

Since I'm using the system's 2.6, I just need to have PyQt installed for that version and I can import it just fine.

I am gonna re-install h12 now, I have 2.5,2.6,2.7 python versions installed. Do I have to do something special with houdini install or it should choose by default the 2.6 version? thanks for the reply.
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
It should use 2.6 by default unless you tell it otherwise by setting an environment variable.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
224 posts
Joined: Nov. 2008
Offline
Just tried out the default PyQt4 dist found on their site, managed to import the Qt module, worked with installed 2.6
Senior Technical Artist Guerrilla Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
graham
On Linux, Houdini will try to use your system version if possible. Houdini only supports 2.5/2.6, defaulting to the 2.6 if available. If it cannot find one of those I believe it will use its internal version. You'll need to see what version your Houdini is running and install PyQt for that build, unless it's using the internal version. The easiest way to check is to just launch Houdini/hython and import something standard and see its path.
import os
>>> os
<module ‘os’ from ‘/usr/lib/python2.6/os.pyc’>

Since I'm using the system's 2.6, I just need to have PyQt installed for that version and I can import it just fine.

I just finished the installation and I have the same problem, python2.6 was installed but houdini chose to use its own python2.6. Here is what I get when I run the os commad:
<module ‘os’ from ‘/opt/hfs12.0.543.9/python/lib/python2.6/os.pyc’>

I cant get it why is this happening.
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
also I tried to append the PyQt4 path on hython's paths and its there but the import PyQt4 is not working again.

>>> import sys
>>> sys.path.append(“/usr/lib/python2.6/dist-packages/PyQt4”)
>>> sys.path

>>> import PyQt4
Traceback (most recent call last):
File “<console>”, line 1, in <module>
ImportError: No module named PyQt4
>>>
User Avatar
Member
224 posts
Joined: Nov. 2008
Offline
Remove “pyQt4” from your path that you append. It should be:

import sys
sys.path.append(“/usr/lib/python2.6/dist-packages”). Make sure you get the installation path right. PyQt4 should be the base module, and has an __init__ file associated with it. Basically descibing it as a package. Simply pointing to the dir that holds the PyQt4 package should suffice.

But you might want to start reading up on python modules / specifics: http://docs.python.org/tutorial/modules.html [docs.python.org]

I also belive the houdini python path in linux will always be configured to point to some specific Houdini modules.

But make sure to read up on some of those Python resources.
Senior Technical Artist Guerrilla Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
cklosters
Remove “pyQt4” from your path that you append. It should be:

import sys
sys.path.append(“/usr/lib/python2.6/dist-packages”). Make sure you get the installation path right. PyQt4 should be the base module, and has an __init__ file associated with it. Basically descibing it as a package. Simply pointing to the dir that holds the PyQt4 package should suffice.

But you might want to start reading up on python modules / specifics: http://docs.python.org/tutorial/modules.html [docs.python.org]

I also belive the houdini python path in linux will always be configured to point to some specific Houdini modules.

But make sure to read up on some of those Python resources.


OK, now PyQT4 is imported without erros, still the questions remains about why Houdini does not use the system's python2.6 when it is there as it should be, based on the documentation.

Thank you very much guys for you patiense and you help.
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
the only problem is that when ever I open hython or houdini I have to append this again and again before PyQt4
User Avatar
Member
224 posts
Joined: Nov. 2008
Offline
i9089303
the only problem is that when ever I open hython or houdini I have to append this again and again before PyQt4

Create or modify a 123.py or 456.py file. These are run when houdini starts and you can use it to append the path variables (or do whatever you like in Python).

http://www.sidefx.com/docs/houdini12.0/hom/independent [sidefx.com]
Senior Technical Artist Guerrilla Games
User Avatar
Member
230 posts
Joined: Oct. 2009
Offline
cklosters
i9089303
the only problem is that when ever I open hython or houdini I have to append this again and again before PyQt4

Create or modify a 123.py or 456.py file. These are run when houdini starts and you can use it to append the path variables (or do whatever you like in Python).

http://www.sidefx.com/docs/houdini12.0/hom/independent [sidefx.com]

thank you for once again!
User Avatar
Member
7734 posts
Joined: July 2005
Offline
Make sure that the environment variable HOUDINI_USE_HFS_PYTHON is unset.
  • Quick Links