win10专业版python3.7,安装VTK一直报错!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win10专业版python3.7,安装VTK一直报错!相关的知识,希望对你有一定的参考价值。

明明提示安装成功
C:\Program Files\Python37>cd Scripts

C:\Program Files\Python37\Scripts>pip install VTK-8.1.1-cp37-none-win_amd64.whl
Processing c:\program files\python37\scripts\vtk-8.1.1-cp37-none-win_amd64.whl
Installing collected packages: VTK
Successfully installed VTK-8.1.1
但是就是报错:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\vtk\vtkCommonCore.py", line 5, in <module>
from .vtkCommonCorePython import *
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python37\lib\site-packages\vtk\__init__.py", line 7, in <module>
from .vtkCommonCore import *
File "C:\Program Files\Python37\lib\site-packages\vtk\vtkCommonCore.py", line 9, in <module>
from vtkCommonCorePython import *
ModuleNotFoundError: No module named 'vtkCommonCorePython'

参考技术A 我这里出现这个原因是没有安装微软的官方系统(我师弟重装了系统, 我就没怎么整理)。需要添加安装c++组件, 用360软件管家安装DirectX修复工具,自动检测安装即可.
只要是系统没问题, 基本上都是直接pip安装就可以成功。我也是折腾了一下午才发现是这个原因, 希望可以帮到你。

[C++][vtk][转载]vtk-8.2.0安装后测试代码示例2.1_RenderCylinde.cpp代码

测试环境:

VS2019专业版

VTK-8.2.0

代码如下:
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCylinderSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkProperty.h>

#include <vtkAutoInit.h> 
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
 
int main()

    vtkSmartPointer<vtkCylinderSource> cylinder =
        vtkSmartPointer<vtkCylinderSource>::New();
    cylinder->SetHeight(3.0);
    cylinder->SetRadius(1.0);
    cylinder->SetResolution(10);
 
    vtkSmartPointer<vtkPolyDataMapper> cylinderMapper =
        vtkSmartPointer<vtkPolyDataMapper>::New();
    cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
 
    vtkSmartPointer<vtkActor> cylinderActor =
        vtkSmartPointer<vtkActor>::New();
    cylinderActor->SetMapper(cylinderMapper);
    cylinderActor->GetProperty()->SetColor(1.0, 0.0, 0.0);
 
    vtkSmartPointer<vtkRenderer> renderer =
        vtkSmartPointer<vtkRenderer>::New();
    renderer->AddActor(cylinderActor);
    renderer->SetBackground(0.1, 0.2, 0.4);
 
    vtkSmartPointer<vtkRenderWindow> renWin =
        vtkSmartPointer<vtkRenderWindow>::New();
    renWin->AddRenderer(renderer);
    renWin->SetSize(640, 480);
    renWin->Render();
    renWin->SetWindowName("RenderCylinder");
 
    vtkSmartPointer<vtkRenderWindowInteractor> iren =
        vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);
 
    iren->Initialize();
    iren->Start();
 
    return 0;

结果:

以上是关于win10专业版python3.7,安装VTK一直报错!的主要内容,如果未能解决你的问题,请参考以下文章

python3.7-3.9安装mayavi教程

python3.7-3.9安装mayavi教程

Python3.7.3安装(Win10)

python3.7安装charts库(Win10系统)

python3.7安装(win10)

Python2.7.16安装(Win10)