Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modules

All questions about installation
Forum rules
Please read the forum usage recommendations before posting.
sciguy

Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modules

Post by sciguy »

Hello
I am using Ubuntu 14.04 and I have compiled and installed Code_Saturne-3.0.5.
After installation, I ran CS with the gui with no problems.

Then a few days later, I tried to run CS again and got this message:
"Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modules.
Please check your PyQt4 installation"

The only change I made since installing CS was that I installed Salome 7.4.0. The Salome instructions say to either run the shell script "salome.sh" in the terminal or in the .bashrc file so it is exectuted before running Salome. This file contains the lines:

export QT4_ROOT_DIR=${INST_ROOT}/qt-4.8.4
export QT_PLUGIN_PATH=${QT4_ROOT_DIR}/plugins
exportp PATH ${QT4_ROOT_DIR}/bin
exportp LD_LIBRARY_PATH ${QT4_ROOT_DIR}/lib[/

Also, I find that the "salome.cfg" file contains the lines:

QT4_ROOT_DIR=%(ROOT_SALOME)s/qt-4.8.4
QT_PLUGIN_PATH=%(QT4_ROOT_DIR)s/plugins
ADD_TO_PATH: %(QT4_ROOT_DIR)s/bin
ADD_TO_LD_LIBRARY_PATH: %(QT4_ROOT_DIR)s/lib

I do not fully understand these files, but it seems that once they are executed, Code Saturne can no longer find the PyQt4.QtCore and PyQt4.QtGui files.

I know this is the problem because I removed the execution of "salome.sh" from the .bashrc file, and tried running Code_Saturne again with its gui and it appeared to run properly and there were no error messages.

So I would like to ask, is there a way, after using Salome, to run a script that would "correct" the locations of PyQt4 files so that CS can find them again? Is there some more clever way to run Salome and Code Saturne independently without this conflict?
Thanks very much for any help on this.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by Yvan Fournier »

Hello,

You would need to restore at least part of the environment to what it was before loading the salome environment:

unset PYTHONATH
unset PYTHONHOME
unset PYTHONSTARTUP
unset PYTHON_INCLUDE

Then remove references to the Salome Python paths in $PATH and $LD_LIBRARY_PATH (easier if you simply save them before starting Salome then restore them).

A simpler an cleaner way is to launch salome in a subshell:

(source salome_environment ; runAppli)

Otherwise, you may build Code_Saturne using Salome's libraries (running the configure step after sourcing the Salome environment should be enough for Python, but you still need to specify where to find HDF5, MED, CGNS, ... so you can chose those of Salome or others). The disadvantage is that when the Salome environment is not sourced, the Python interpreter used by Code_Saturne (that of Salome in this case) won't even start, as it needs the appropriate LD_LIBRARY_PATH value to find its libraries.

Finally, if you install Code_Satune with Salome support (--with-salome= configure option), you should be able to run Salome from Code_Saturne (launching it with "code_saturne salome") while only sourcing the Salome environment in a subshell, so when you exit, you original environment is not changed.

Regards,

Yvan
sciguy

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by sciguy »

Hello Yvan
Thanks very much for your response. I will try one of your suggestions, probably the last one.

I installed CS using the "Automatic Install" via the python script: install_saturne.py. Your last suggestion, which uses the -- with salome configure option, does this apply only to the "Manual Install" procedure? Is there a way to install CS, using the --with salome configure option, and also using the python script, install_saturne.py for the automatic install? If not, I will try to install CS from scratch again, following the manual install procedure, and incorporating the with salome configure option.

It was only after I had already installed it that I learned about the add-on called CFDSTUDY. Is your last suggestion equivalent to incorporating the CFDSTUDY module?
Thanks again,
Richard
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by Yvan Fournier »

Hello,

You can use the automatic install to prepare the manual install:
when using the automatic install, the Code requires a build directory, and the install creates a config.log file in that directory. Near the top of the file, you will find a the log of a command with "configure". Copy-paste that command, add --with-salome=<path_to_salome>, let the configure command run, then run "make && make install".

Regards,

Yvan
sciguy

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by sciguy »

Hello Yvan
I appreciate your help! Now I am stuck again and hope that you can make a further suggestion.
I followed your last suggestion -- using the configure command from the log file, and added --with salome=<path to salome> to the command. I ran it, and I did the make and make install.
This was successful to a point. The CFDSTUDY interface is present in Salome; I am following the CFDSTUDY tutorial. However, when I press the Check Mesh button, everything goes ok until the end where an error message is produced:

/home/richard/Code_Saturne/code_saturne-3.0.5/libexec/code_saturne/cs_solver was built without XML support,
so parameter file "cs_cmd" may not be loaded

On this forum, a user solved this problem by installing libxml2-dev. I used ubuntu's software manager to download and install this package. Then I tried the config command, make, make install again. The problem is still present. I have tried several other procedures, such as adding the following to the configure command:
--with-libxml2=/usr/include/libxml2/libxml

But I get error messages during the make process, which crashes out, saying that: /libxml/tree.h or /libxml/parser.h No such file or directory. But I have checked that these files exist in the directory: /usr/include/libxml2/libxml and tree.h and parser.h are all present.
Do you have any further suggestion as to how to correct this problem?

Thanks very much
Richard
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by Yvan Fournier »

Hello,

Did you start from a "fresh" (empty) build directory ? Could you post the files recommended for this forum ?

Regards,

Yvan
sciguy

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by sciguy »

cs_config.h
(10.04 KiB) Downloaded 307 times
config.log
(262.57 KiB) Downloaded 329 times
[attachment=0]
Hello Yvan
Thanks for your reply.
Here are the details you requested:
Code Saturne Version: 3.0.5
System/Machine: A single Dell PC, Optiplex 9010, 8 GB RAM, Ubuntu 14.04
Third Party Tools: gcc 4:4.8.2-1ubuntu6
gfortran 4:4.8.2-1ubuntu6
pyqt4-dev-tools 4.10.4+dfsg-1ubuntu1; python-qt4 4.10.4+dfsg-1ubuntu1
hdf5-1.8.10
cgnslib_3.2.1
med-3.0.7
openmpi-1.6.5

I have tried to attach the config files config.log, config.status, and cs_config.h but I'm not sure I followed the correct procedure. Please let me know if you need further information.

Before executing the config command, I completely cleared the directory: code_saturne-3.0.5.build
This directory is under the directory: installer_3.0.5 which I have not touched.

The config command included the line: --with-libxml2=/usr/include/ but I have also tried: --with-libxml2=/usr/include/libxml2 with the same result.

If you inspect the config.log file (if the attachment worked), you can see that there is a Fatal Error reported:
fatal error: libxml/parser.h: No such file or directory
#include <libxml/parser.h>

Thank you for your help, and please let me know if there is further information that you need.
Richard
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by Yvan Fournier »

Hello,

Your syntax for libxml2 is not correct:
--with-libxml2-include=/usr/include
would be OK, but if you want to add --with-libxml2, it should be:
--with-libxml2-include=/usr/include

Did you try not adding --with-libxml2 to the configure options ?
As it is in the default system directory, it should be found automatically.

Also, make sure the libxml2-dev package is installed (our test for libxml2 is not so great:
if --with-libxml2* is passed, it ignores the test for headers, and may fail later). We'll have to improve that.

Regards,

Yvan
sciguy

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by sciguy »

Hello Yvan
I cleared the build directory again, and I removed the --with-libxml2 from the config command.
The config command ran with no errors that I saw, as did the make, and make install commands. However, when I ran code_saturne salome, and followed the CFDSTUDY tutorial, I again tried Check Mesh, and unfortunately, still got the message:

home/richard/Code_Saturne/code_saturne-3.0.5/libexec/code_saturne/cs_solver was built without XML support,
so parameter file "cs_cmd" may not be loaded

I have attached the corresponding config.log file as config_1.log.

I also again cleared the build directory, and added the --with-libxml2-include=/usr/include to the config command. I ran configure again, and there did not seem to be any errors in the config.log file. But when I ran the make command, there was an error reported in the terminal:

home/richard/Downloads/installer_3.0.5/code_saturne-3.0.5/src/gui/cs_gui.c:47:25: fatal error: libxml/tree.h: No such file or directory
#include <libxml/tree.h>
^
compilation terminated.
make[3]: *** [cs_gui.lo] Error 1
make[3]: Leaving directory `/home/richard/Downloads/installer_3.0.5/code_saturne-3.0.5.build/src/gui'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/richard/Downloads/installer_3.0.5/code_saturne-3.0.5.build/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/richard/Downloads/installer_3.0.5/code_saturne-3.0.5.build'
make: *** [all] Error 2

And the make process was terminated.

I have attached the config.log file corresponding to this run as config_2.log
Yes, the libxml2-dev package is installed.

Anything further you can suggest?
Regards,
Richard
Attachments
config_2.log
(287.24 KiB) Downloaded 293 times
config_1.log
(288.18 KiB) Downloaded 307 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error: Unable to import PyQt4.QtCore or PyQt4.QtGui modu

Post by Yvan Fournier »

Hello,

I seems that the Salome environment might add to the confusion, but for finer control, you may try forcing both the includes (which, I just checked, should be in /usr/include/libxml2/libxml, with Code_Saturne adding the libxml part), and the rest:
--with-libxml2-include=/usr/include/libxml2 --with-libxml2=/usr
or, for Salome's version, replace /usr with the appropriate path.

If this still fails, could you post the output of:
find /usr/include -name parser.h
Regards,

Yvan
Post Reply