简体   繁体   English

vtk构建成功,但是python表示模块不存在?

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

I'm building vtk on Cent OS. 我在Cent OS上构建vtk I would like to install the python wrappers, and I've followed the build directions to do so. 我想安装python包装器,并且按照构建说明进行安装。

I've installed under prefix ~/local . 我已经安装在前缀~/local Things appear to have gone successfully: 事情似乎已经成功完成:

vtk , vtkpython , and other vtk executables appear in my ~/local/bin/ directory. vtkvtkpython和其他vtk可执行文件出现在我的~/local/bin/目录中。 vtk libraries appear in ~/local/lib . vtk库出现在~/local/lib

However, when I run python -c "import vtk" , I see: 但是,当我运行python -c "import vtk" ,我看到:

ImportError: No module named vtk ImportError:没有名为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 : 这是一个似乎出现在相关问题上的特定shell变量的值:

echo $LD_LIBRARY_PATH
=> ~/local/lib

Check where is the python module. 检查python模块在哪里。 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 ..). 在我的系统中(不是按照这些说明来构建VTK,但不应太不同),在lib / python2.6 / site-packages / vtk /中有一个文件夹,其中包含__init__.py和所有vtk类(例如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). 如果找到该文件夹​​,则将其父文件夹添加到PYTHONPATH环境变量中(或在python分发site-packages文件夹中,创建一个包含该文件夹的文件vtk.pth)。 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 另请参见http://www.vtk.org/Wiki/VTK/Tutorials/PythonEnvironmentSetup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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