CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (http://www.cfd-online.com/Forums/openfoam-installation/)
-   -   paraview and python install problem (http://www.cfd-online.com/Forums/openfoam-installation/119569-paraview-python-install-problem.html)

laurent98 June 19, 2013 21:31

paraview and python install problem
 
hi all,
sorry for asking such a simple problem but i really face it since 2 days!
i want to run paraview in batch mode or just get a pic with a python script. and i am not a expert !!!

so i compile paraFoam with makeParaView setup
withPYTHON=true
PYTHON_LIBRARY="/usr/lib/libpython3.2mu.so.1.0"
# PYTHON_LIBRARY="/usr/lib64/libpython2.6.so.1.0"

# MESA graphics support:
withMESA=false
MESA_INCLUDE="/usr/include/GL"
MESA_LIBRARY="/usr/lib64/libOSMesa.so"

# extra QT gui support (useful for some third party apps)
withQT=true

# Set the path to the Qt-4.5 (or later) qmake if the system Qt is older
QMAKE_PATH=""

# Set the path to cmake
CMAKE_PATH=""

i add in the .bachrc file
export PYTHONPATH=$PYTHONPATH:/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/Utilities/VTKPythonWrapping/site-packages #fixes "no module named paraview"
export PYTHONPATH=$PYTHONPATH:/home/laurent/OpenFOAM/ThirdParty-2.2.0/platforms/linuxGcc/paraview-3.12.0/bin #fixes "ImportError: No module named libvtkCommonPython"

and when i run idle3 python i have this message.
Python 3.2.1 (default, Jul 18 2011, 16:24:40) [GCC] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import paraview
>>> from paraview.simple import *
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from paraview.simple import *
File "/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/Utilities/VTKPythonWrapping/site-packages/paraview/simple.py", line 134
raise RuntimeError, "File not readable: %s " % first_file
^
SyntaxError: invalid syntax

any help will ve very welcome because i am going mad!!!
thank by advance LL

wyldckat June 20, 2013 15:54

Greetings laurent98,

I'm not sure if ParaView 3.12.0 can handle Python 3.2.

Any chance you can indicate which Linux Distribution you are using? This way I could try and reproduce the problem.

Best regards,
Bruno

laurent98 June 20, 2013 19:15

hi Bruno,
thanks a lot for your help.
i am using opensuse 12.1
i had try also with python 2.7 still not running but this different message came from idle interpretor;

Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import paraview
>>> from paraview.simple import *

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from paraview.simple import *
File "/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/Utilities/VTKPythonWrapping/site-packages/paraview/simple.py", line 40, in <module>
import servermanager
File "/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/Utilities/VTKPythonWrapping/site-packages/paraview/servermanager.py", line 43, in <module>
import paraview, re, os, os.path, new, sys, vtk
File "/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/Utilities/VTKPythonWrapping/site-packages/paraview/vtk/__init__.py", line 1, in <module>
from vtkCommonPython import *
ImportError: No module named vtkCommonPython
>>>

i really don t know what to do???
best regards LL

PonchO June 23, 2013 06:46

Hi folks,

i have exactly the same problem. I have exported the paths as this page says: http://paraview.org/Wiki/ParaView/Py....simple_Module but it doesn't work.

My LD_LIBRARY_PATH links to the folder where the vtkCommonCorePython.so should be.
I mentioned if it is a 64Bit .so so i do a file-command.
This gives me:
Code:

file vtkCommonCorePython.so
vtkCommonCorePython.so: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b20cbc6de288730f94f5d4301cfc661ba9d2ac44, stripped

So it's 64Bit and should work on my system.

System Specifications:

Manjaro 0.8.6
python 2.7.5 and python 3.3.2
paraview 4.0.1
LD_LIBRARY_PATH: :/opt/opencascade/lib:/usr/lib/python2.7:/usr/lib
PYTHONPATH: :/usr/lib/python2.7/site-packages/:/usr/lib/paraview-4.0/site-packages/

I am using Python just for scripting and evaluation and plotting of my results, but i think this can be used more powerful, if i can couple paraview to that.
So laurent98, if you have found a solution to this, please share :).

Best Regards,

Christoph

wyldckat June 23, 2013 13:05

Greetings to all!

OK, to address first laurent98's problem, I've done the following steps in a virtual machine with openSUSE 12.1 64bit (x86_64). laurent98 has got 32bit, but I'll try to keep the instructions generic enough.

@Christoph: Try the instructions below, but only starting from the section for the python shell and beyond.



For installing, I followed the instructions from here: http://openfoamwiki.net/index.php/In...#openSUSE_12.2 - but I made some changes in the following steps:
  • In step #1, I also installed "python-devel":
    Code:

    zypper install python-devel
  • In step #7, I ran makeParaView like this:
    Code:

    ./makeParaView -python
    It detected Python 2.7 automatically, which is why I did not modify the makeParaView script.
  • Still on step #7, after makeParaView has finished running, run the following command:
    Code:

    cp $WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION/bin/vtk*.so $ParaView_DIR/lib/paraview-$ParaView_MAJOR/
Then to set-up the Python environment, I added the following lines in "~/.bashrc", after the line for OpenFOAM that ends with bashrc:
Code:

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


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 *


And that's it!


Now, there is one important detail: pvpython is the advised application for interacting with Python + ParaView. To run it, simply run:
Code:

pvpython

Best regards,Bruno

PonchO June 23, 2013 13:31

Hi Bruno,

thank you for your quick reply.

Unfortunately it still doesn't work :(.

Same error as before:

As you said i start with:
Code:

import paraview
import vtk
from paraview.simple import *

But then as always:

Code:

Error: Could not import vtkCommonComputationalGeometryPython
---------------------------------------------------------------------------
ImportError                              Traceback (most recent call last)
<ipython-input-7-fd18706122a4> in <module>()
----> 1 from paraview.simple import *

/usr/lib/paraview-4.0/site-packages/paraview/simple.py in <module>()
    39 paraview.compatibility.major = 3
    40 paraview.compatibility.minor = 5
---> 41 import servermanager
    42
    43 #==============================================================================

/usr/lib/paraview-4.0/site-packages/paraview/servermanager.py in <module>()
    46 #
    47 #==============================================================================
---> 48 import paraview, re, os, os.path, new, sys, atexit, vtk
    49
    50 if not paraview.compatibility.major:

/usr/lib/paraview-4.0/site-packages/paraview/vtk/__init__.py in <module>()
      5 except ImportError:
      6    paraview.print_error("Error: Could not import vtkCommonComputationalGeometryPython")
----> 7 from vtkCommonCorePython import *
      8 from vtkCommonDataModelPython import *
      9 from vtkCommonExecutionModelPython import *

ImportError: No module named vtkCommonCorePython

Now i recognize, that there is a problem besides the vtkCommonCorePython regarding the vtkCommonComputationalGeometryPython at the top of the error-message.

Do you have an idea? Should i start from scratch and compile paraview by myself?

Best regards,

Christoph

wyldckat June 23, 2013 13:33

Hi Christoph,

Without knowing which Linux Distribution you're using and how you installed ParaView, it's very complicated to figure out what the solution is.

Nonetheless, as I indicated in the last few lines of the previous post, pvpython is advised for interacting with ParaView.

Best regards,
Bruno

PonchO June 23, 2013 14:52

I'm using an ArchLinux-based distro called Manjaro. So i access the Arch User Repository in which the paraview package is. A tool compiles the whole Paraview.

I think i will start compiling it by myself and then go to the next step with pvpython.

Thanks up to this point. I will report if i've found a solution.

Best regards,

Christoph

laurent98 June 26, 2013 17:12

hi Bruno,
thank you very much for your help, it is very nice of you. i made some progress in the installation. it seems that python -devel qt4-x11-tools ... was missing.
i still have some problemes;
after makeparaview -python the tail of terminal log is;

...
/home/laurent/OpenFOAM/ThirdParty-2.2.0/ParaView-3.12.0/VTK/Wrapping/Python/vtkPythonArgs.cxx:117:28: error: ‘PyInt_AsLong’ was not declared in this scope
make[2]: *** [VTK/Wrapping/Python/CMakeFiles/vtkPythonCore.dir/vtkPythonArgs.cxx.o] Error 1
make[1]: *** [VTK/Wrapping/Python/CMakeFiles/vtkPythonCore.dir/all] Error 2
make: *** [all] Error 2
---
Installation complete for paraview-3.12.0
Set environment variables:

export ParaView_DIR=/home/laurent/OpenFOAM/ThirdParty-2.2.0/platforms/linuxGcc/paraview-3.12.0
export PATH=$ParaView_DIR/bin:$PATH
export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-3.12
---

Done

looks like there is a problem with vtk because there is no files vtk*.so here the message after the cp comand;

linux-juf1:/home/laurent/OpenFOAM/ThirdParty-2.2.0 # cp $WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION/bin/vtk*.so $ParaView_DIR/lib/paraview-$ParaView_MAJOR/
cp: cannot stat `/home/laurent/OpenFOAM/ThirdParty-2.2.0/build/linuxGcc/paraview-3.12.0/bin/vtk*.so': No such file or directory

i have look inside the directory$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION/bin/ there is some libvtk*.so or others *vtk*.so but nothink like vtk*.so ???

finally in the python interpreter i get;
>>> from QVTKPython import *
RuntimeError: the sip module implements API v8.0 to v8.1 but the vtk.QVTKPython module requires API v10.0
>>>

in which direction should i go???
thanks you again, best regards LL

wyldckat June 27, 2013 17:28

Hi Laurent,

I think I know what the problem is. You probably have the two python versions installed: 2.7 and 3.2. But the makeParaView script is having trouble figuring out which Python version should be used.

If I'm not mistaken, it's possibly picking up the python application version 3.2 and the include folder only exists for 2.7. But first, confirm if the following command gives you anything:
Code:

ls -l /usr/include/python2.7
It should show you the contents of the folder that makeParaView needs and that should have been provided by the "python-devel" package.

Then check which Python version it is picking up, by running:
Code:

python --version
If it gives you 3.2.x, then this is the big problem, because the wrong version is being picked up, because you need 2.7 to be picked up.

Best regards,
Bruno

laurent98 June 28, 2013 11:25

P { margin-bottom: 0.21cm; } Dear Bruno,
thanks you SO much! It is great, very nice of you to help people as you are doing!
You were perfectly right, the problem came from the 2 versions installed of python. So, before to makeParaview I just put in the makeparaview files;


withPYTHON=true
PYTHON_LIBRARY="/usr/lib/libpython2.7.so.1.0"


now ,
laurent@linux-juf1:~> pvpython
Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paraview
>>> from paraview.simple import *
paraview version 3.12.0, Date: 2011-07-26
>>>


run ok
still import vtk have this problem


>>> import vtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/vtk/__init__.py", line 127, in <module>
from qvtk import *
File "/usr/lib/python2.7/site-packages/vtk/qvtk.py", line 8, in <module>
from QVTKPython import *
RuntimeError: the sip module implements API v8.0 to v8.1 but the vtk.QVTKPython module requires API v10.0
>>>


but I don't know if it is important, I have to play now with python script to do what I went!
hope this can help others person, thanks again to Bruno!
best regards LL

Luchini February 6, 2014 10:13

Hi,

i have some problems on this too.

First makeParaView does not recognize my python, so i did:

Code:

withPYTHON=true
PYTHON_LIBRARY="/usr/lib/libpython2.7.so.1.0"

When run makeParaView at the end i had this error:

Code:

QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:
Cannot open data base file /home/flucci/OpenFOAM/ThirdParty-2.2.x/build/linux64Gcc/paraview-3.12.0/Documentation/paraview.qch!
make[2]: *** [Documentation/paraview.qch] Error 255
make[1]: *** [Documentation/CMakeFiles/ParaViewOnlineHelp.dir/all] Error 2
make: *** [all] Error 2
    ---
    Installation complete for paraview-3.12.0
    Set environment variables:

        export ParaView_DIR=/home/flucci/OpenFOAM/ThirdParty-2.2.x/platforms/linux64Gcc/paraview-3.12.0
        export PATH=$ParaView_DIR/bin:$PATH
        export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-3.12
    ---

Done

but since it was on the documentation i moved on.
I tried to update the PYTHONPATH but both :/usr/lib/python2.7/ and :$ParaView_DIR/lib/paraview-3.12/ do not have the site-packages subdirectories.


Moreover if i do :

Code:

import paraview
import vtk
from paraview.simple import *

I get:

Code:

:~/OpenFOAM/ThirdParty-2.2.x$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paraview
>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/vtk/__init__.py", line 41, in <module>
    from vtkCommonPython import *
ImportError: /home/flucci/Programs/visit/2.6.2/linux-x86_64/lib/libvtkPythonCore.so.5.8: undefined symbol: PyUnicodeUCS2_DecodeUTF8
>>> from paraview.simple import *
Segmentation fault (core dumped)

Does anybody knows what went wrong?



few more inputs:
i use Ubuntu,
OF 2.2.X

if i run pvpython i also have :
Code:

:~/OpenFOAM/ThirdParty-2.2.x$ pvpython
Error converting executable file "/usr/bin/../lib/paraview/pvpython" to real path: No such file or directory


THANK YOU A LOT

wyldckat February 6, 2014 18:00

Greetings Luca,

Can you specify which version of Ubuntu you are using, so that I can try and replicate the same problem? :)

Best regards,
Bruno

Luchini February 7, 2014 04:33

Hi Bruno,

Thank you a lot ( again) for your help.

I have the 12.04 LTS.

If this procedure is too long is it possible to link paraFoam to a later paraview installtion?
(i have an executable of the paraview 4.1 already with the python included..)

thank you a lot

wyldckat February 15, 2014 11:53

Hi Luca,

Sorry for the late reply. I had a better, yet quick read, of the two posts you've written and the diagnosis is that VisIt is getting in the way. You should make sure that you start with a clean shell environment and then activate only OpenFOAM's shell environment. Then proceed on to building ParaView.
If you're not familiar with the shell environment, have a look into this wiki page: http://openfoamwiki.net/index.php/In...with_the_Shell

If after using a clean shell environment, without interference from VisIt, you still have problems, let us know!

As for using a pre-built ParaView 4.1.0:

Best regards,
Bruno

luigi412 December 12, 2014 20:33

Dear all;
Thank for your previous post. I am still not able to use the "Python Shell" in paraview.
Unfortunatly I still have this error when I try to start trace:
>>> from paraview.simple import *
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
import paraview, re, os, os.path, new, sys, vtk
File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
from vtkCommonPython import *
ImportError: No module named vtkCommonPython

I am using ubuntu 12.04 with OF 2.2.1 and paraview 3.12.0 It seems like vtkCommonPython is not existing on my pc.
Do you have any idea how to solve my problem?
thank you very much!
Luigi

wyldckat December 13, 2014 16:12

Greetings Luigi and welcome to posting on the forum!

The error message you're seeing looks familiar to me... have a look at this bug report, which has a solution for this: http://www.openfoam.org/mantisbt/view.php?id=969
More specifically, this solution: http://www.cfd-online.com/Forums/ope...tml#post446490 post #17

Best regards,
Bruno


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