CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

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

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

Like Tree3Likes
  • 3 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2014, 08:31
Default paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7
  #1
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 145
Rep Power: 13
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, 09:15
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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)
SailorLiu, aylalisa and Romarius like this.

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

Old   June 13, 2014, 09:25
Default
  #3
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 145
Rep Power: 13
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, 09:34
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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, 09:52
Default
  #5
Senior Member
 
Join Date: Nov 2012
Location: Bavaria
Posts: 145
Rep Power: 13
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 Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.com] Trouble building Paraview from ThirdPartyv1812 folder with python and mpi support praphul OpenFOAM Installation 4 April 8, 2019 02:26
[General] Building Paraview 4.1.0 with MPI and Python support reynoldsStress ParaView 10 July 27, 2017 09:38
[foam-extend.org] Error compiling OpenFOAM-1.6-ext Canesin OpenFOAM Installation 137 January 20, 2016 15:56
Python support when building Paraview ? francois OpenFOAM Installation 2 June 16, 2014 16:37
Compilation error OF1.5-dev on Suse10.3 darenyang OpenFOAM Installation 0 April 29, 2009 05:55


All times are GMT -4. The time now is 22:39.