CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7 (http://www.cfd-online.com/Forums/openfoam-paraview/137301-paraview-v4-building-python-of2-3-0-pvv4-python-2-7-a.html)

aylalisa June 13, 2014 07:31

paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7
 
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

alexeym June 13, 2014 08:15

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 June 13, 2014 08:25

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

alexeym June 13, 2014 08:34

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.

aylalisa June 13, 2014 08:52

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 :confused:

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.


All times are GMT -4. The time now is 17:52.