简体   繁体   中英

vtk build succeeds but python says module doesn't exist?

I'm building vtk on Cent OS. I would like to install the python wrappers, and I've followed the build directions to do so.

I've installed under prefix ~/local . Things appear to have gone successfully:

vtk , vtkpython , and other vtk executables appear in my ~/local/bin/ directory. vtk libraries appear in ~/local/lib .

However, when I run python -c "import vtk" , I see:

ImportError: No module named vtk

So apparently, something is not correctly pointing to something else, although I'm not sure what I'm missing since I've followed the build directions.

Here is the value of a particular shell variable that seems to show up on a related question :

echo $LD_LIBRARY_PATH
=> ~/local/lib

Check where is the python module. In my system (where VTK was not built following those instructions, but should not be too different) there is a folder in lib/python2.6/site-packages/vtk/ , which contains __init__.py and all the vtk classes (eg vtkCommonCore.py , vktCommonCorePython.so ..). If you find that folder, add its parent folder to the PYTHONPATH environment variable (or in your python distribution site-packages folder, create a file vtk.pth which contains that folder). So, in my system, I have:

export PYTHONPATH=/mypath/INSTALL/lib/python2.6/site-packages/:$PYTHONPATH

See also http://www.vtk.org/Wiki/VTK/Tutorials/PythonEnvironmentSetup

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM