CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Problems with PyFoam (http://www.cfd-online.com/Forums/openfoam/98792-problems-pyfoam.html)

Christoph_84 March 19, 2012 11:37

Problems with PyFoam
 
Hallo,

I'm trying to install PyFoam, I use OpenFoam 1.7.1 on OpenSuse 11.4. I tried it several times , with the description of the Wiki, as user and as root. Some applications work others not. One imported Application is pyFoamDisplayBlockMesh.py but I got that Error:

Code:

Trying VTK implementation from Paraview
 Traceback (most recent call last):
  File "/home/nonroot/my_python/bin/pyFoamDisplayBlockMesh.py", line 5, in <module>
    from PyFoam.Applications.DisplayBlockMeshQt import DisplayBlockMesh
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 30, in <module>
    doImports()
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 28, in doImports
    error("Error while importing modules:",e)
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Error.py", line 49, in error
    raise FatalErrorPyFoamException(*text)
 PyFoam.Error.FatalErrorPyFoamException: FatalError in PyFoam: 'PyFoam FATAL ERROR on line 28 of file /usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py: Error while importing modules: No module named paraview'

Can anybody help me?

gschaider March 19, 2012 12:14

Quote:

Originally Posted by Christoph_84 (Post 350229)
Hallo,

I'm trying to install PyFoam, I use OpenFoam 1.7.1 on OpenSuse 11.4. I tried it several times , with the description of the Wiki, as user and as root. Some applications work others not. One imported Application is pyFoamDisplayBlockMesh.py but I got that Error:

Code:

Trying VTK implementation from Paraview
 Traceback (most recent call last):
  File "/home/nonroot/my_python/bin/pyFoamDisplayBlockMesh.py", line 5, in <module>
    from PyFoam.Applications.DisplayBlockMeshQt import DisplayBlockMesh
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 30, in <module>
    doImports()
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 28, in doImports
    error("Error while importing modules:",e)
  File "/usr/local/lib/python2.7/site-packages/PyFoam/Error.py", line 49, in error
    raise FatalErrorPyFoamException(*text)
 PyFoam.Error.FatalErrorPyFoamException: FatalError in PyFoam: 'PyFoam FATAL ERROR on line 28 of file /usr/local/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py: Error while importing modules: No module named paraview'

Can anybody help me?

When you look at the output of pyFoamVersion.py you will see that VTK (a requirement for that utility) is missing. You'll have to install that (make sure that the python and the QT-bindings are installed if your system has them in separate packages). While you're add it: check the output of pyFoamVersion.py for PyQT4. If that is missing: it is required too

Christoph_84 March 20, 2012 04:16

Thank you Bernhard,


I installed the missing libraries an now it works and I can starting to discover PyFoam!


Christoph

gschaider March 20, 2012 06:26

Quote:

Originally Posted by Christoph_84 (Post 350359)
Thank you Bernhard,


I installed the missing libraries an now it works and I can starting to discover PyFoam!


Christoph

I never stressed those libraries as requirements as they're not necessary for the majority of the tools

RomW November 28, 2012 12:09

needs help to find my mistake
 
Hello everyone,

I am struggling to get the following command to behave.

Code:

pyFoamDisplayBlockMesh.py constant/polyMesh/blockMeshDict
I get:

Quote:

Using system-VTK
PyFoam WARNING on line 282 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Applications/DisplayBlockMeshQt.py : While reading constant/polyMesh/blockMeshDict this happened: 'patches'
Traceback (most recent call last):
File "/usr/local/bin/pyFoamDisplayBlockMesh.py", line 11, in <module>
DisplayBlockMesh()
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 744, in __init__
nr=1)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PyFoamApplicationQt4.py", line 37, in __init__
exactNr=exactNr)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PyFoamApplication.py", line 155, in __init__
result=self.run()
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PyFoamApplicationQt4.py", line 59, in run
self.setupGUI()
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 751, in setupGUI
self.dialog=DisplayBlockMeshDialog(bmFile)
File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 283, in __init__
raise e
I think that I installed all the required libraries because when I run:

Code:

pyFoamVersion.py
I get the following output:


Quote:

PYTHONPATH: not set
OpenFOAM (2, 0, 1) of the installed versions []
pyFoam-Version: 0.5.5
Configuration search path: [('file', '/etc/pyFoam/pyfoamrc'), ('directory', '/etc/pyFoam/pyfoamrc.d'), ('file', '/home/romain/.pyFoam/pyfoamrc'), ('directory', '/home/romain/.pyFoam/pyfoamrc.d')]
Configuration files (used): []

Installed libraries:
Gnuplot : Yes
ply : No Not a problem. Version from ThirdParty is used
Numeric : No Not a problem if numpy is present
numpy : Yes
matplotlib : Yes
psyco : No Not a problem. Acceleration not possible
hotshot : Yes
profile : Yes
cProfile : Yes
PyQt4 : Yes
PyQt4.Qwt5 : No Only an alternate plotting back-end
vtk : Yes
Tkinter : Yes
mercurial : Yes
PyQt4 -> checked
vtk -> checked

The only issue seems to be the PYTHONPATH. Does anyone now what I have to set in my ~/.bashrc?

gschaider November 28, 2012 14:59

Quote:

Originally Posted by RomW (Post 394689)
Hello everyone,

I am struggling to get the following command to behave.

Code:

pyFoamDisplayBlockMesh.py constant/polyMesh/blockMeshDict
I get:



I think that I installed all the required libraries because when I run:

Code:

pyFoamVersion.py
I get the following output:




PyQt4 -> checked
vtk -> checked

The only issue seems to be the PYTHONPATH. Does anyone now what I have to set in my ~/.bashrc?

Well. The error message means that the problem occurred during the reading of the blockMeshDict.

vtk and PyQT4 are there (according to pyFoamVersion) and have already been loaded during that state of the problem. You don't have to set the PYTHONPATH (this output is mainly there to find out whether other libraries than the system versions are used).

You followed the first rule of pyFoam-Error-Reporting: pyFoamVersion. And this leads to the probable problem: your version is rather old (0.5.5) and was definitely released before 2.0. In that version (at least as far as I remember) the format of the blockMeshDict changed (especially with the patches). Current versions are tolerant about this but 0.5.5 can't possibly know about this.

Solution: install the current pyFoam-version (0.5.7). If the version you're using is system-wide installed and you can't easily replace it, then install it locally in your account and THEN you have to set PYTHONPATH

RomW November 29, 2012 07:20

Thank you very much Bernhard. I did not check there was a newer version of PyFoam before installing PyFoam 0.5.5, big mistake, thank you for pointing this out.

When I install PyFoam 0.5.7 the same way I installed the previous version, when I run:

pyFoamVersion.py

I still get as output that I am using PyFoam 0.5.5 version

Do you know how I could overwrite it? :D

Thank you very much
Rom

gschaider November 29, 2012 10:45

Quote:

Originally Posted by RomW (Post 394843)
Thank you very much Bernhard. I did not check there was a newer version of PyFoam before installing PyFoam 0.5.5, big mistake, thank you for pointing this out.

When I install PyFoam 0.5.7 the same way I installed the previous version, when I run:

pyFoamVersion.py

I still get as output that I am using PyFoam 0.5.5 version

Do you know how I could overwrite it? :D

Thank you very much
Rom

Did you do it like this:
http://openfoamwiki.net/index.php/Co...a_regular_user

Probably you've got to set PYTHONPATH (and also PATH) to you installation so that it "shadows" the system-installation

RomW November 29, 2012 12:46

Quote:

Originally Posted by gschaider (Post 394870)
Did you do it like this:
http://openfoamwiki.net/index.php/Co...a_regular_user

Probably you've got to set PYTHONPATH (and also PATH) to you installation so that it "shadows" the system-installation

After setting the PYTHONPATH (and also PATH), it worked just fine.

Amazing piece of software, really thanks Bernhard for simplifying OpenFOAM with PyFoam.

RomW November 30, 2012 10:59

Quote:

Originally Posted by gschaider (Post 394870)
Did you do it like this:
http://openfoamwiki.net/index.php/Co...a_regular_user

Probably you've got to set PYTHONPATH (and also PATH) to you installation so that it "shadows" the system-installation

Sorry Bernhard to ask so many basic questions, but when i run pyFoamPlotRunner.py, i actually do not get any plots, is that behaviour normal?

gschaider November 30, 2012 13:20

Quote:

Originally Posted by RomW (Post 395031)
Sorry Bernhard to ask so many basic questions, but when i run pyFoamPlotRunner.py, i actually do not get any plots, is that behaviour normal?

No it is not. Usually the first plot windows should pop up once pyFoam found the second timestep in the output. It does so by looking for the usual time string "Time = x.xxx" in the output. If that is different for a solver (happens) another pattern can be specified

DDB January 1, 2013 09:42

Hi, I am very new to all this (inc forums) and very frustrated!!

I can't get pyFoamDisplayBlockMesh.py constant/polyMesh/blockMeshDict to work, so any help would be gratefully appreciated!

pyFoamDisplayBlockMesh.py constant/polyMesh/blockMeshDict

gives

Traceback (most recent call last):
File "/usr/bin/pyFoamDisplayBlockMesh.py", line 5, in <module>
from PyFoam.Applications.DisplayBlockMeshQt import DisplayBlockMesh
File "/usr/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 33, in <module>
doImports()
File "/usr/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py", line 31, in doImports
error("Error while importing modules:",e)
File "/usr/lib/python2.7/site-packages/PyFoam/Error.py", line 49, in error
raise FatalErrorPyFoamException(*text)
PyFoam.Error.FatalErrorPyFoamException: FatalError in PyFoam: 'PyFoam FATAL ERROR on line 31 of file /usr/lib/python2.7/site-packages/PyFoam/Applications/DisplayBlockMeshQt.py: Error while importing modules: No module named paraview'

and

pyFoamVersion.py

gives

Python version: 2.7.3 (default, Jul 24 2012, 10:05:38)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)]

PYTHONPATH: /usr/lib64/python2.7/site-packages/openmpi

OpenFOAM (2, 1, 1) of the installed versions ['2.1.1']

pyFoam-Version: 0.5.7

Configuration search path: [('file', '/etc/pyFoam/pyfoamrc'), ('directory', '/etc/pyFoam/pyfoamrc.d'), ('file', '/home/natalie/.pyFoam/pyfoamrc'), ('directory', '/home/natalie/.pyFoam/pyfoamrc.d')]
Configuration files (used): []

Installed libraries:
Gnuplot : Yes version: 1.8
ply : No Not a problem. Version from ThirdParty is used
Numeric : No Not supported anymore. No need to install it
numpy : Yes version: 1.6.2
matplotlib : No Only Gnuplot-plotting possible
psyco : No Not a problem. Acceleration not possible
hotshot : Yes
profile : Yes
cProfile : Yes
PyQt4 : Yes
PyQt4.Qwt5 : No Only an alternate plotting back-end
vtk : No Not a problem. Only used for some utilities
Tkinter : Yes version: $Revision: 81008 $
mercurial : No Not a problem. Used for experimental case handling


but

Package vtk-5.8.0-6.fc17.x86_64 already installed and latest version
Package paraview-3.14.1-3.fc17.x86_64 already installed and latest version


I have installed as root and there is nothing in my .bashrc for pyFoam...

Please help!

wyldckat January 1, 2013 10:25

Greetings DDB and welcome to the forum!

The answer was given on the second post:
Quote:

Originally Posted by gschaider (Post 350240)
[...] (make sure that the python and the QT-bindings are installed if your system has them in separate packages). While you're add it: check the output of pyFoamVersion.py for PyQT4. If that is missing: it is required too

It looks like you've got Fedora 17 installed. I think you need to install the following packages:
Code:

vtk-python vtk-qt pyqt4
Which you can install by running as root:
Code:

yum install vtk-python vtk-qt pyqt4
Best regards,
Bruno

PS: If OpenFOAM's plugins for ParaView are properly installed and you have at least OpenFOAM 2.0.0, then you can use the following command as well:
Code:

paraFoam -block

DDB January 1, 2013 10:37

Hi wyldckat, Thank you very much for your help! It works now!

Your instructions look very different to the 2nd post though, so I am not surprised a newbie like me didn't understand!!

simone.rowing April 27, 2013 14:35

PyFoam mac displayblockmesh error
 
I have a mac lion 1.7, and recently installed OpenFOAM 2.1 with paraview 3.14.1. I am interested in using PyFoam. Already installed 0.6 using the guides on the openfoam wiki site. Unfortunately find an error which I cannot fix:
Quote:

MacBook-di-Simone:cavity simomartini$ pyFoamDisplayBlockMesh.py constant/polyMesh/blockMeshDict
PyFoam WARNING on line 11 of file /usr/local/bin/pyFoamDisplayBlockMesh.py : Falling back to the old Tkinter-implementation because no PyQT4 was found
Trying VTK implementation from Paraview
Error in /usr/local/bin/pyFoamDisplayBlockMesh.py : FatalError in PyFoam: 'PyFoam FATAL ERROR on line 29 of file /Library/Python/2.7/site-packages/PyFoam/Applications/DisplayBlockMesh.py: Error while importing modules: No module named paraview'
MacBook-di-Simone:cavity simomartini$
this props up when using the pyFoamDisplayBlockMesh.py command. I suspect the paraview path has not been set correctly. here is my bashrc commands:

Quote:

alias of21='hdiutil attach "/Users/simomartini/OpenFOAM-v2.1.sparseimage" -mountpoint "$HOME/OpenFOAM" > /dev/null ; . $HOME/OpenFOAM/OpenFOAM-2.1.0/etc/bashrc'

alias paraview="/Applications/'Paraview_3.14.1.app'/Contents/MacOS/paraview"
alias emacs="/Applications/'Aquamacs.app'/Contents/MacOS/Aquamacs"
alias parax="touch case.foam && paraview --data=case.foam &"
alias paraFoam="paraFoam -builtin"
please assist on fixing this issues. also any ideas on where i could find a solution would be great. we have been looking on the forums for a day now but nothing seems to be applicable.

wyldckat April 28, 2013 06:22

Greetings Simone and welcome to the forum!

This is roughly on section 10.4: http://openfoamwiki.net/index.php/Co...paraview-stuff

But since this installation on Mac OS X uses a pre-built ParaView version... a quick hack would be to add the following code to before or after that the code in "bashrc" that you've provided:
Code:

ParaView_DIR="/Applications/Paraview_3.14.1.app/Contents/MacOS/"
if [ "$PYTHONPATH" ]; then
    export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping
else
    export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping
fi

Although you need to check if these are indeed the paths you've got in your installation. I say this because I don't have a Mac to test this on :D

Best regards,
Bruno

gschaider April 28, 2013 17:15

Quote:

Originally Posted by wyldckat (Post 423593)
Greetings Simone and welcome to the forum!

This is roughly on section 10.4: http://openfoamwiki.net/index.php/Co...paraview-stuff

But since this installation on Mac OS X uses a pre-built ParaView version... a quick hack would be to add the following code to before or after that the code in "bashrc" that you've provided:
Code:

ParaView_DIR="/Applications/Paraview_3.14.1.app/Contents/MacOS/"
if [ "$PYTHONPATH" ]; then
    export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping
else
    export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping
fi

Although you need to check if these are indeed the paths you've got in your installation. I say this because I don't have a Mac to test this on :D

Best regards,
Bruno

I'm afraid there is no such directory in the Mac-binary (so this won't work)

In my experience the easiest way to get a VTK that works with pyFoamDisplayBlockMesh.py on a Mac is to use MacPorts. Something like

port install vtk5 +python27 +qt4_mac

should install it with python and QT-support (if you use a different python adapt it). Also use

port install py27-pyqt4

if PyQT is not yet installed

simone.rowing May 2, 2013 04:50

PyFoam
 
this reply is in response to the last 2 posts. initially we tried wyldckat's suggestion and that got us past the paraview error provided we supplied the correct addresses for the paraview installation folder (different from the post). However we had a different PyQt4 error immediately after.
after that we tried the macports installation of PyQt4 etc... as described by gschaider, however we still get the original paraview error in this case. So far I have set pyqt4 module folder "/opt/local/share/py27-sip/PyQt4" to be added to PYTHONPATH and tried to confirm this by doing "import PyQt4" i get an error that module doesnt exist. On the internet it does say there is a support problem for PyQt4 and Mac lion OSX, so we are sort of stuck. the suggestion on the web is to fiddle with the installation package, but we're not sure how to do this. if there is any suggestion on how to do this plz help!

gschaider May 4, 2013 06:49

Quote:

Originally Posted by simone.rowing (Post 424586)
this reply is in response to the last 2 posts. initially we tried wyldckat's suggestion and that got us past the paraview error provided we supplied the correct addresses for the paraview installation folder (different from the post). However we had a different PyQt4 error immediately after.
after that we tried the macports installation of PyQt4 etc... as described by gschaider, however we still get the original paraview error in this case. So far I have set pyqt4 module folder "/opt/local/share/py27-sip/PyQt4" to be added to PYTHONPATH and tried to confirm this by doing "import PyQt4" i get an error that module doesnt exist. On the internet it does say there is a support problem for PyQt4 and Mac lion OSX, so we are sort of stuck. the suggestion on the web is to fiddle with the installation package, but we're not sure how to do this. if there is any suggestion on how to do this plz help!

It shouldn't be necessary to set the PYTHONPATH ... if the pyqt4 you installed is for your currently used Python. Try the following

- Start python and on the Python-Shell try importing it: "import PyQt4"
- run pyFoamVersion.py and post the result here

simone.rowing May 8, 2013 15:30

dear geschaider, after a bit of fiddling with the folders, we have the PyQt4 installed and able to import it in python. the vtk package must also be installed, however it shows the following erro after runnung the code "pyFoamVersion.py"
Code:

Installed libraries:
Gnuplot              :  No      Not a problem. Version from ThirdParty is used
ply                  :  No      Not a problem. Version from ThirdParty is used
Numeric              :  No      Not supported anymore. No need to install it
/Applications/Paraview_3.98.1.app/Contents/Python/numpy/random/__init__.py:87: RuntimeWarning: compiletime version 2.6 of module 'mtrand' does not match runtime version 2.7
  from mtrand import *
numpy                :  Yes      version: 1.6.2
matplotlib          :  Yes      version: 1.1.1
psyco                :  No      Not a problem. Acceleration not possible
hotshot              :  Yes
profile              :  Yes
cProfile            :  Yes
PyQt4                :  Yes
PyQt4.Qwt5          :  No      Only an alternate plotting back-end
vtk                  :  Error: Could not import vtkCommonComputationalGeometryPython
No      Not a problem. Only used for some utilities
Tkinter              :  Yes      version: $Revision: 81008 $
mercurial            :  No      Not a problem. Used for experimental case handling
nose                :  No      Only needed for running the unit-tests (developers only)
twisted              :  Yes      version: 11.0.0
pandas              :  No      Not yet used. Maybe handling of timelines will be reimplemented with it
scipy                :  No      Not yet used. Possibly use signal-fitting etc

not entirely sure what to do next, many thanks for the help so far.


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