CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Paraview & paraFoam

paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Display Modes
Old   June 13, 2014, 07:31
Default paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7
  #1
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 144
Rep Power: 4
aylalisa is on a distinguished road
Hi Foamers,

since I want to use the feature Edit | Find Data in ParaView v4 I've successfully followed wyldckat's instructions.

To set-up the Python environment, I added the following lines in "~/.bashrc", after the line for OpenFOAM that ends with bashrc:

Quote:
source /home/user/OpenFOAM/OpenFOAM-2.2.0/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI
#added these lines
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/lib/paraview-3.12/site-packages
Quote:
Start a new shell terminal. Then run python:
Code:
python

Now, within the python shell, run:
Code:
import paraview
import vtk
from paraview.simple import *
The red marked line induces an error:

Code:
Error: Could not import vtkCommonComputationalGeometryPython
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/elisabeth/OpenFOAM/ThirdParty-2.3.0/platforms/linux64Gcc/ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/simple.py", line 41, in <module>
    import servermanager
  File "/home/elisabeth/OpenFOAM/ThirdParty-2.3.0/platforms/linux64Gcc/ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/servermanager.py", line 48, in <module>
    import paraview, re, os, os.path, new, sys, atexit, vtk
  File "/home/elisabeth/OpenFOAM/ThirdParty-2.3.0/platforms/linux64Gcc/ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/vtk/__init__.py", line 7, in <module>
    from vtkCommonCorePython import *
ImportError: No module named vtkCommonCorePython
Quote:
Now,
there is one important detail: pvpython is the advised application for interacting with Python + ParaView. To run it, simply run:
Code:
pvpython
The last step works, I can start the interpreter from shell.

Does the error cause further problems?

Aylalisa
aylalisa is offline   Reply With Quote

Old   June 13, 2014, 08:15
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,089
Rep Power: 19
alexeym will become famous soon enoughalexeym will become famous soon enough
Hi,

This line is for PV 3.12

Code:
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/lib/paraview-3.12/site-packages
while, according to your error, you've got version 4.1.0. So if your PV is really built with python support export should be something like:

Code:
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/lib/paraview-4.1/site-packages:$ParaView_DIR/lib/paraview-4.1/site-packages/vtk
and then you can

Code:
$ python
Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
paraview version 4.1.0
>>>
(tested on openSUSE 13.1)
aylalisa likes this.

Last edited by alexeym; June 13, 2014 at 08:16. Reason: typo
alexeym is offline   Reply With Quote

Old   June 13, 2014, 08:25
Default
  #3
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 144
Rep Power: 4
aylalisa is on a distinguished road
Hi Alexey,

my .bashrc file

Code:
PYTHONPATH=$PYTHONPATH:/usr/lib64/python2.7/site-packages
PYTHONPATH=$PYTHONPATH:/home/aylalisa/OpenFOAM/ThirdParty-2.3.0/platforms/linux64Gcc/ParaView-4.1.0/lib/paraview-4.1/site-packages
export PYTHONPATH
Aylalisa

According to your path /vtk is missing.

I've add /vtk --> it works. I get this output, too! Thank you!



Aylalisa
aylalisa is offline   Reply With Quote

Old   June 13, 2014, 08:34
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,089
Rep Power: 19
alexeym will become famous soon enoughalexeym will become famous soon enough
Hi,

in my code snippet there was .../paraview-4.1/site-packages but also .../paraview-4.1/site-packages/vtk.

Without second entry I had the following error:

Code:
$ export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/lib/paraview-4.1/site-packages
$ python
Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
Error: Could not import vtkCommonComputationalGeometryPython
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/simple.py", line 41, in <module>
    import servermanager
  File ".../ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/servermanager.py", line 48, in <module>
    import paraview, re, os, os.path, new, sys, atexit, vtk
  File ".../ParaView-4.1.0/lib/paraview-4.1/site-packages/paraview/vtk/__init__.py", line 7, in <module>
    from vtkCommonCorePython import *
ImportError: No module named vtkCommonCorePython
>>>
while with the second folder in PYTHONPATH:

Code:
$ export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/lib/paraview-4.1/site-packages:$ParaView_DIR/lib/paraview-4.1/site-packages/vtk
$ python
Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
paraview version 4.1.0
>>>
Though if I use pvpython, I even don't need to modify PYTHONPATH.
alexeym is offline   Reply With Quote

Old   June 13, 2014, 08:52
Default
  #5
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 144
Rep Power: 4
aylalisa is on a distinguished road
The only change I made was to add site-packages/vtk at the end of the second path variable set-up.

Before that change I've received the error. After changing and sourcing .bashrc I've received...

Code:
>>> from paraview.simple import*
paraview version 4.1.0
>>>
...the desired output

PYTHONPATH was not set at all on my system. But honestly speaking, I have not tried pvpython before. Am at the beginning concerning usage of python with openfoam and paraview.
aylalisa is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building Paraview 4.1.0 with MPI and Python support reynoldsStress ParaView 9 January 24, 2015 14:32
How to get Python Shell into ParaView 3.8.1? blaise OpenFOAM Installation 3 July 24, 2012 04:58
Error compiling OpenFOAM-1.6-ext Canesin OpenFOAM Installation 136 April 25, 2012 11:22
ParaView 3.8.0 problem on debian Unseen OpenFOAM Installation 4 August 16, 2010 10:26
Compilation error OF1.5-dev on Suse10.3 darenyang OpenFOAM Installation 0 April 29, 2009 04:55


All times are GMT -4. The time now is 23:50.