CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Problems using pyFoamPVLoadState.py (http://www.cfd-online.com/Forums/openfoam-post-processing/77848-problems-using-pyfoampvloadstate-py.html)

gautcho July 6, 2010 06:08

Problems using pyFoamPVLoadState.py
 
Hello everybody,

I do my first steps with pyFoam and it works out very well so long, but now i try to use some state-files of paraview using

"pyFoamPVLoadState.py --state==teststate.pvsm cavity"

The result is an error message:

"
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPVLoadState.py", line 3, in <module>
from PyFoam.Applications.PVLoadState import PVLoadState
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PVLoadState.py", line 11, in <module>
from PyFoam.Paraview.ServermanagerWrapper import ServermanagerWrapper as SM
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Paraview/__init__.py", line 15, in <module>
from paraview import servermanager
ImportError: No module named paraview
"

Paraview 3.6.1 is installed, so what does this error mean and how can I avoid it...

gschaider July 6, 2010 10:27

Quote:

Originally Posted by gautcho (Post 265905)
Hello everybody,

I do my first steps with pyFoam and it works out very well so long, but now i try to use some state-files of paraview using

"pyFoamPVLoadState.py --state==teststate.pvsm cavity"

The result is an error message:

"
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPVLoadState.py", line 3, in <module>
from PyFoam.Applications.PVLoadState import PVLoadState
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PVLoadState.py", line 11, in <module>
from PyFoam.Paraview.ServermanagerWrapper import ServermanagerWrapper as SM
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Paraview/__init__.py", line 15, in <module>
from paraview import servermanager
ImportError: No module named paraview
"

Paraview 3.6.1 is installed, so what does this error mean and how can I avoid it...

I'm afraid it is a Paraview without Python support (check if there is an entry "Python Shell" in the "Tools" menu. If it isn't there, then you habve no Python-support)

Bernhard

gautcho July 13, 2010 10:55

Thanks, I think, you got it.

Do you know any tutorial or anything like this describing how to activate the python support???

Regrads

gschaider July 14, 2010 03:00

Quote:

Originally Posted by gautcho (Post 267070)
Thanks, I think, you got it.

Do you know any tutorial or anything like this describing how to activate the python support???

Regrads

I'm afraid you'll have to recompile paraview. The makeParaview-script in the ThirdParty-folder provides a switch -python that enables Python-support. Have a look at the messages in the beginning whether it finds the system-Python. If not you'll have to set the PYTHON_SOMETHING-variable in that script. Be aware that due to changes in the API for loading Plugins there might be problems with loading the PV3Reader in 3.6 (native reader should be OK). If I remember it correctly PVLaodState works, PVSnapshot does not.

Bernhard

alfa_8C September 22, 2010 06:05

Hello Gautcho,

I have currently the same problem and I tried to switch all the SET(ENABLE_PYTHON = OFF) to SET(ENABLE_PYTHON = ON) stuff into several files within the ThirdParty directory. But after recompiling they are all set again to OFF!! There must be an other "switch" to manipulate. Did you find out how to do it? I took just a look into the makeParaviw script, but I couldn't make clearly out any option to switch ON or OFF the PYTHON support...

Thanx in advance for any input,
Antonio

gschaider September 22, 2010 09:43

Quote:

Originally Posted by alfa_8C (Post 276124)
Hello Gautcho,

I have currently the same problem and I tried to switch all the SET(ENABLE_PYTHON = OFF) to SET(ENABLE_PYTHON = ON) stuff into several files within the ThirdParty directory. But after recompiling they are all set again to OFF!! There must be an other "switch" to manipulate. Did you find out how to do it? I took just a look into the makeParaviw script, but I couldn't make clearly out any option to switch ON or OFF the PYTHON support...

Thanx in advance for any input,
Antonio

You mean "recompiling with the makeParaview-script". That one generates the configuration anew. But it has a -python-option that configures Paraview with Python. Otherwise don't edit the fles by hand, but use ccmake

Bernhard

alfa_8C September 22, 2010 10:29

Hello Bernhard,

yes exactly I mean the makeParaView Script..

I want to install Paraview with Python support in order to be able to use your contribution, and I'm following this hin on OpenFoamWiki:

http://openfoamwiki.net/index.php/Us...s/Installation

This is how it looks like within my makeParaView script after modifying it:

# Python support:
# note: script will try to determine the appropriate python library.
# If it fails, specify the path using the PYTHON_LIBRARY variable
withPYTHON=true
#PYTHON_LIBRARY=""
PYTHON_LIBRARY="/usr/lib/libpython2.6.so.1.0"
PYTHON_INCLUDE="/usr/include/python2.6"

According to the OpenFoamWiki I changed also the File: $WM_PROJECT_INST_DIR/ThirdParty-1.6.x/tools/makeParaViewFunctions.

When I run then the makeParaView script again, it starts quite well until this step:

Scanning dependencies of target vtkWrapPython
Scanning dependencies of target vtkWrapPythonInit
[ 0%] [ 0%] Building C object VTK/Wrapping/CMakeFiles/vtkWrapPython.dir/vtkWrapPython.c.o
Building C object VTK/Wrapping/CMakeFiles/vtkWrapPythonInit.dir/vtkWrapPythonInit.c.o

After this step it breaks up saying: this file not found
that file not found
the other file not found

what am I doing wrong??? Any Idea??

gschaider September 22, 2010 12:40

Quote:

Originally Posted by alfa_8C (Post 276186)
Hello Bernhard,

yes exactly I mean the makeParaView Script..

I want to install Paraview with Python support in order to be able to use your contribution, and I'm following this hin on OpenFoamWiki:

http://openfoamwiki.net/index.php/Us...s/Installation

This is how it looks like within my makeParaView script after modifying it:

# Python support:
# note: script will try to determine the appropriate python library.
# If it fails, specify the path using the PYTHON_LIBRARY variable
withPYTHON=true
#PYTHON_LIBRARY=""
PYTHON_LIBRARY="/usr/lib/libpython2.6.so.1.0"
PYTHON_INCLUDE="/usr/include/python2.6"

According to the OpenFoamWiki I changed also the File: $WM_PROJECT_INST_DIR/ThirdParty-1.6.x/tools/makeParaViewFunctions.

When I run then the makeParaView script again, it starts quite well until this step:

Scanning dependencies of target vtkWrapPython
Scanning dependencies of target vtkWrapPythonInit
[ 0%] [ 0%] Building C object VTK/Wrapping/CMakeFiles/vtkWrapPython.dir/vtkWrapPython.c.o
Building C object VTK/Wrapping/CMakeFiles/vtkWrapPythonInit.dir/vtkWrapPythonInit.c.o

After this step it breaks up saying: this file not found
that file not found
the other file not found

what am I doing wrong??? Any Idea??

No idea. Best way to find out what went wrong is (I'm doing this from memory so be creative with commands and stuff) is go to the directory where compilation takes palce (this is something newly created ... not the source dir). There start the cmake-"GUI" with "ccmake .", Look for an option "Verbose MAkefiles". Switch that on. Check whether all the Python-related-stuff is OK. Then let it generate new makefiles. Start compilation manually with "make" in that directory. You should now get the exact command that failed

alfa_8C September 24, 2010 08:50

Hy Bernhard,

thank you very much for your input. I didn't have even ccmake installed, and it's in fact far easier to handle!

But unfortunately it didn't solve my problem - I found the newly built directory and I checked all the PYTHON related options.
1)They are set all to ON.
2)Besides I switched the CMAKE Verbose Make option to ON as well,
3)and then configured with ccmake.
It configures fine no error!! But in Paraview the Python Shell Option under Tools is still deactivated. And your pyFoam script doesn't work neither - No module named paraview!

If I try to run "make" in the current directory after having completed point 3) - I receive the Error listed below.

p@poyry:~/OpenFOAM/ThirdParty-1.7.1/...araview-3.8.0$ make
[ 0%] Building C object VTK/Wrapping/CMakeFiles/vtkWrapPython.dir/vtkWrapPython.c.o
In file included from /home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Common/vtkPython.h:46,

from /home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Wrapping/vtkWrapPython.c:16:

/home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Common/Python.h:7:24: error: patchlevel.h: No such file or directory

Do I have to set an environment variable or somthing??
The only one I set is in my .bashrc for OpenFAOM!!! That's it!

gschaider September 24, 2010 15:02

Quote:

Originally Posted by alfa_8C (Post 276512)
Hy Bernhard,

thank you very much for your input. I didn't have even ccmake installed, and it's in fact far easier to handle!

But unfortunately it didn't solve my problem - I found the newly built directory and I checked all the PYTHON related options.
1)They are set all to ON.
2)Besides I switched the CMAKE Verbose Make option to ON as well,
3)and then configured with ccmake.
It configures fine no error!! But in Paraview the Python Shell Option under Tools is still deactivated. And your pyFoam script doesn't work neither - No module named paraview!

If I try to run "make" in the current directory after having completed point 3) - I receive the Error listed below.

p@poyry:~/OpenFOAM/ThirdParty-1.7.1/...araview-3.8.0$ make
[ 0%] Building C object VTK/Wrapping/CMakeFiles/vtkWrapPython.dir/vtkWrapPython.c.o
In file included from /home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Common/vtkPython.h:46,

from /home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Wrapping/vtkWrapPython.c:16:

/home/poyry/OpenFOAM/ThirdParty-1.7.1/paraview-3.8.0/VTK/Common/Python.h:7:24: error: patchlevel.h: No such file or directory

Do I have to set an environment variable or somthing??
The only one I set is in my .bashrc for OpenFAOM!!! That's it!

patchlevel.h is a header that belongs to the Python-development-stuff. Have a look whether a package python-devel or similar is installed on your system.

Bernhard

alfa_8C October 25, 2010 12:49

Hello Bernhard,

finally I could enable the python support in my Paraview
but unfortunately neither the loadstate nor the snapshot tool works...
I receive still the same error message:

poyry@CHZRH-WS-C10176:~/OpenFOAM/poyry-1.7.1/run/tutorials/incompressible/icoFoam/cavity$ pyFoamPVLoadState.py --state=cavity.psvm cavity
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPVLoadState.py", line 3, in <module>
from PyFoam.Applications.PVLoadState import PVLoadState
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PVLoadState.py", line 11, in <module>
from PyFoam.Paraview.ServermanagerWrapper import ServermanagerWrapper as SM
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Paraview/__init__.py", line 15, in <module>
from paraview import servermanager
ImportError: No module named paraview

It is strange - other applications of PyFoam like pyFoamPlotWatcher.py work well!

Any idea?

gschaider October 27, 2010 05:55

Quote:

Originally Posted by alfa_8C (Post 280680)
Hello Bernhard,

finally I could enable the python support in my Paraview
but unfortunately neither the loadstate nor the snapshot tool works...
I receive still the same error message:

poyry@CHZRH-WS-C10176:~/OpenFOAM/poyry-1.7.1/run/tutorials/incompressible/icoFoam/cavity$ pyFoamPVLoadState.py --state=cavity.psvm cavity
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPVLoadState.py", line 3, in <module>
from PyFoam.Applications.PVLoadState import PVLoadState
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PVLoadState.py", line 11, in <module>
from PyFoam.Paraview.ServermanagerWrapper import ServermanagerWrapper as SM
File "/usr/local/lib/python2.6/dist-packages/PyFoam/Paraview/__init__.py", line 15, in <module>
from paraview import servermanager
ImportError: No module named paraview

It is strange - other applications of PyFoam like pyFoamPlotWatcher.py work well!

Any idea?

Seems like the directory with the pythonbindings is missing from the PYTHONPATH. Check in the PYTHONPATH all the directories with paraview in the name (there should be one)

Bernhard

alfa_8C October 27, 2010 11:52

your hint led my in the right direction.

my variable or alias or whatever "$ParaView_DIR" that is used in the etc/apps/paraview/bashrc-file led me to the wrong path. Once set the whole right path instead of "$ParaView_DIR" within the paths containing "Utilities" in the etc/apps/paraview/bashrc-file, the pyFoamPVLoadState.py worked, whereas the snapshot utility still fails. but But there is a hint, that this is something ralated to all OF versions >=1.6.

Is this still an unsolved problem? If yes - are there other possibilities to do automatized postprozessing?

Best regards and thank you again for the hint,
Antonio

gschaider October 28, 2010 05:46

Quote:

Originally Posted by alfa_8C (Post 281033)
your hint led my in the right direction.

my variable or alias or whatever "$ParaView_DIR" that is used in the etc/apps/paraview/bashrc-file led me to the wrong path. Once set the whole right path instead of "$ParaView_DIR" within the paths containing "Utilities" in the etc/apps/paraview/bashrc-file, the pyFoamPVLoadState.py worked, whereas the snapshot utility still fails. but But there is a hint, that this is something ralated to all OF versions >=1.6.

Is this still an unsolved problem? If yes - are there other possibilities to do automatized postprozessing?

Best regards and thank you again for the hint,
Antonio

That is a rather nasty problem where the loading of Plugins does not work as advertised (and fails differently on different OSs and Paraview-versions) which makes the loading of PV3Reader-plugins fail. What should work is if you have a paraview with the "good" native raider built in (v.3.8 and higher) and you postprocessed with "touch test.foam;paraview" instead of paraFoam to generate snapshots. If that fails for you too please give me the error message you're getting

Bernhard


All times are GMT -4. The time now is 16:25.