问题
I am trying to run this Python file using pvpython [filename].py
from paraview.simple import *
servermanager.Connect()
#sphere = Sphere();
#Show();
import os
i = 0
SubDir = [" "]*30
# Set the directory you want to start from
rootDir = '/var/www/html/php/emd/job552e23fe74d102/VTK'
for dirName, subdirList, fileList in os.walk(rootDir):
if dirName == rootDir + '/others':
continue
if dirName == rootDir:
continue
SubDir.append(dirName)
i=i+1
print('Found directory: %s' % dirName)
for fname in fileList:
print('\t%s' % fname)
j=1
j= LegacyVTKReader( FileNames=[dirName + '/' + fname] )
and I am getting this error
File "paraview.py", line 2, in <module>
from paraview.simple import *
File "/var/www/html/php/emd/job552e23fe74d102/VTK/paraview.py", line 2, in <module>
from paraview.simple import *
ImportError: No module named simple
Is there anywhere I have gone wrong. Please help me, I am a beginner in this.
回答1:
This happens to me if I do not add the directory that holds the ParaView Libraries to the LD_LIBRARY_PATH system variable. I have ParaView 4.0.1 installed as an example and I append the path to the variable as follows in Ubuntu:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/sgeadmin/ParaView-4.0.1-Linux-64bit/lib/paraview-4.0
来源:https://stackoverflow.com/questions/29923266/how-to-run-a-paraview-python-code-using-pvbatch-or-pv-python