我是在docker容器里安装,里面的环境是python3,因此mayavi依赖的PyQT需要安装PyQT5,现在PyCharm的python package tool window里左上方的搜索栏里输入PyQt5然后点击右上方的Install安装包PyQt5,然后在搜索栏输入vtk 选择安装最新的9.2.2版,然后在搜索栏里输入mayavi,也选择latest版本进行安装,结果试了几次都失败,选择了mayavi低一点的几个版本试了也不行,每次都是类似下面segment fault的错误:

Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting mayavi
  Using cached https://mirrors.aliyun.com/pypi/packages/8a/54/90dd60c62e685ee56bdfaa6a7af62b0c762568a962e3137fc954b4f845bc/mayavi-4.8.0.tar.gz (19.8 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: apptools in /usr/local/lib/python3.6/site-packages (from mayavi) (5.2.0)
Requirement already satisfied: envisage in /usr/local/lib/python3.6/site-packages (from mayavi) (6.1.0)
Requirement already satisfied: numpy in /root/.local/lib/python3.6/site-packages (from mayavi) (1.19.5)
Requirement already satisfied: pyface>=6.1.1 in /usr/local/lib/python3.6/site-packages (from mayavi) (7.4.2)
Requirement already satisfied: pygments in /usr/local/lib/python3.6/site-packages (from mayavi) (2.12.0)
Requirement already satisfied: traits>=6.0.0 in /usr/local/lib64/python3.6/site-packages (from mayavi) (6.4.1)
Requirement already satisfied: traitsui>=7.0.0 in /usr/local/lib/python3.6/site-packages (from mayavi) (7.4.1)
Requirement already satisfied: vtk in /usr/local/lib64/python3.6/site-packages (from mayavi) (9.2.2)
Requirement already satisfied: importlib-resources>=1.1.0 in /usr/local/lib/python3.6/site-packages (from pyface>=6.1.1->mayavi) (5.4.0)
Requirement already satisfied: importlib-metadata>=3.6.0 in /usr/local/lib/python3.6/site-packages (from pyface>=6.1.1->mayavi) (4.8.3)
Requirement already satisfied: configobj in /usr/local/lib/python3.6/site-packages (from apptools->mayavi) (5.0.6)
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/site-packages (from envisage->mayavi) (59.5.0)
Requirement already satisfied: wslink>=1.0.4 in /usr/local/lib/python3.6/site-packages (from vtk->mayavi) (1.8.2)
Requirement already satisfied: matplotlib>=2.0.0 in /usr/local/lib64/python3.6/site-packages (from vtk->mayavi) (3.3.4)
Requirement already satisfied: typing-extensions>=3.6.4 in /root/.local/lib/python3.6/site-packages (from importlib-metadata>=3.6.0->pyface>=6.1.1->mayavi) (4.1.1)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/site-packages (from importlib-metadata>=3.6.0->pyface>=6.1.1->mayavi) (3.6.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.6/site-packages (from matplotlib>=2.0.0->vtk->mayavi) (1.2.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->vtk->mayavi) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->vtk->mayavi) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in /root/.local/lib/python3.6/site-packages (from matplotlib>=2.0.0->vtk->mayavi) (8.4.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.6/site-packages (from matplotlib>=2.0.0->vtk->mayavi) (3.0.9)
Requirement already satisfied: aiohttp<4 in /usr/local/lib64/python3.6/site-packages (from wslink>=1.0.4->vtk->mayavi) (3.8.1)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from configobj->apptools->mayavi) (1.16.0)
Requirement already satisfied: idna-ssl>=1.0 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (1.1.0)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib64/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (1.2.0)
Requirement already satisfied: asynctest==0.13.0 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (0.13.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (4.0.2)
Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (21.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (1.2.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib64/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (5.2.0)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /usr/local/lib/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (2.0.12)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib64/python3.6/site-packages (from aiohttp<4->wslink>=1.0.4->vtk->mayavi) (1.7.2)
Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.6/site-packages (from idna-ssl>=1.0->aiohttp<4->wslink>=1.0.4->vtk->mayavi) (2.8)
Building wheels for collected packages: mayavi
  Building wheel for mayavi (setup.py): started
  Building wheel for mayavi (setup.py): finished with status 'error'
  Running setup.py clean for mayavi
Failed to build mayavi
Installing collected packages: mayavi
    Running setup.py install for mayavi: started
    Running setup.py install for mayavi: finished with status 'error'

ERROR: Command errored out with exit status -11:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-4s0oq87x
       cwd: /tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/
  Complete output (153 lines):
  running bdist_wheel
  running build
  ----------------------------------------------------------------------
  Deleting possibly old TVTK classes
  Building TVTK classes... vtkAnimationCue: Ignoring method: Get/SetDirection
  default: 1, range: None
  vtkContextDevice2D: Ignoring method: Get/SetViewportRect
  default: [225, 0, 37940736, 0], range: None
  vtkContextDevice2D: Ignoring method: Get/SetViewportSize
  default: [41, 0], range: None
  vtkEventDataForDevice: Ignoring method: Get/SetAction
  default: -1, range: None
  vtkEventDataForDevice: Ignoring method: Get/SetDevice
  default: -1, range: None
  vtkFXAAOptions: Ignoring method: Get/SetDebugOptionValue
  default: 0, range: None
  vtkIncrementalForceLayout: Ignoring method: Get/SetGravityPoint
  default: [200.0, 200.0], range: None
  vtkOpenGLBufferObject: Ignoring method: Get/SetType
  default: 0, range: None
  vtkOpenGLFXAAFilter: Ignoring method: Get/SetDebugOptionValue
  default: 0, range: None
  vtkRenderWidget: Ignoring method: Get/SetPosition
  default: [0, 0], range: None
  vtkRenderWidget: Ignoring method: Get/SetSize
  default: [300, 300], range: None
  vtkShader: Ignoring method: Get/SetType
  default: 3, range: None
  vtkVolumeTexture: Ignoring method: Get/SetPartitions
  default: [1, 1, 1], range: None
  vtkChartMatrix: Ignoring method: Get/SetFillStrategy
  default: 0, range: None
  vtkChartMatrix: Ignoring method: Get/SetGutter
  default: [15.0, 15.0], range: None
  vtkChartMatrix: Ignoring method: Get/SetRect
  default: [0, 0, 100, 100], range: None
  vtkChartMatrix: Ignoring method: Get/SetSize
  default: [0, 0], range: None
  vtkContextArea: Ignoring method: Get/SetDrawAreaBounds
  default: [0.0, 0.0, 300.0, 300.0], range: None
  vtkContextArea: Ignoring method: Get/SetDrawAreaResizeBehavior
  default: 0, range: None
  vtkContextArea: Ignoring method: Get/SetFixedMargins
  default: [0, 0, 0, 0], range: None
  vtkContextArea: Ignoring method: Get/SetFixedRect
  default: [0, 0, 300, 300], range: None
  vtkContextArea: Ignoring method: Get/SetGeometry
  default: [0, 0, 300, 300], range: None
  vtkImplicitProjectOnPlaneDistance: Ignoring method: Get/SetNorm
  default: 2, range: None
  vtkOpenGLVertexBufferObject: Ignoring method: Get/SetCoordShiftAndScaleMethod
  default: 0, range: None
  vtkSimple3DCirclesStrategy: Ignoring method: Get/SetMarkedValue
  default: (invalid), range: None
  vtkArrayNorm: Ignoring method: Get/SetWindow
  default: [0, 9223372036854775807), range: None
  vtkChart: Ignoring method: Get/SetSize
  default: [0.0, 0.0, 0.0, 0.0], range: None
  vtkChartXYZ: Ignoring method: Get/SetAxisColor
  default: [0, 0, 0, 255], range: None
  vtkEuclideanClusterExtraction: Radius not updatable (VTK 9.1 bug - value not properly initialized)
  Warning: We cannot determine the trait type of vtkHigherOrderHexahedron.Order
  Warning: We cannot determine the trait type of vtkHigherOrderQuadrilateral.Order
  Warning: We cannot determine the trait type of vtkHigherOrderWedge.Order
  vtkHyperTreeGridPreConfiguredSource: Ignoring method: Get/SetCustomArchitecture
  default: 0, range: None
  vtkHyperTreeGridPreConfiguredSource: Ignoring method: Get/SetHTGMode
  default: 0, range: None
  vtkLightingMapPass: Ignoring method: Get/SetRenderType
  default: 0, range: None
  vtkPlot: Ignoring method: Get/SetShiftScale
  default: [0.0, 0.0, 1.0, 1.0], range: None
  vtkScatterPlotMatrix: Ignoring method: Get/SetActivePlot
  default: [0, -2], range: None
  vtkScatterPlotMatrix: Ignoring method: Get/SetScatterPlotSelectedActiveColor
  default: [0, 204, 0, 102], range: None
  vtkScatterPlotMatrix: Ignoring method: Get/SetScatterPlotSelectedRowColumnColor
  default: [204, 0, 0, 102], range: None
  vtkScatterPlotMatrix: Ignoring method: Get/SetSize
  default: [0, 0], range: None
  vtkSparseArray_I10vtkVariantE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_I10vtkVariantE: Ignoring method: Get/SetNullValue
  default: (invalid), range: None
  vtkSparseArray_I12vtkStdStringE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IaE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IcE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IdE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IfE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IhE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IiE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IjE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IlE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_ImE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IsE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_ItE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IxE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkSparseArray_IyE: Ignoring method: Get/SetExtents
  default: , range: None
  vtkThresholdTable: Ignoring method: Get/SetMaxValue
  default: 2147483647, range: None
  vtkThresholdTable: Ignoring method: Get/SetMinValue
  default: 0, range: None
  vtkTransferAttributes: Ignoring method: Get/SetDefaultValue
  default: 1, range: None
  Bad to call vtkUniformHyperTreeGrid::GetXCoordinates
  Bad to call vtkUniformHyperTreeGrid::GetYCoordinates
  Bad to call vtkUniformHyperTreeGrid::GetZCoordinates
  vtkChartBox: Ignoring method: Get/SetSize
  default: [0.0, 0.0, 0.0, 0.0], range: None
  vtkColorLegend: Ignoring method: Get/SetPosition
  default: [0.0, 0.0, 0.0, 0.0], range: None
  Warning: We cannot determine the trait type of vtkImageMask.MaskedOutputValue
  vtkMolecule: Ignoring method: Get/SetLatticeOrigin
  default: [0.0, 0.0, 0.0], range: None
  vtkPOpenFOAMReader: Ignoring method: Get/SetCaseType
  default: 1, range: None
  Fatal Python error: Segmentation fault
  
  Current thread 0x00007f39ab5c0740 (most recent call first):
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/vtk_parser.py", line 705 in _find_get_set_methods
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/vtk_parser.py", line 488 in _organize_methods
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/vtk_parser.py", line 154 in parse
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/wrapper_gen.py", line 341 in _gen_methods
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/wrapper_gen.py", line 242 in generate_code
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/code_gen.py", line 235 in _write_wrapper_class
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/tvtk/code_gen.py", line 142 in generate_code
    File "tvtk/setup.py", line 98 in gen_tvtk_classes_zip
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py", line 254 in build_tvtk_classes_zip
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py", line 268 in run
    File "/usr/lib64/python3.6/distutils/dist.py", line 974 in run_command
    File "/usr/lib64/python3.6/distutils/cmd.py", line 313 in run_command
    File "/usr/local/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 299 in run
    File "/usr/lib64/python3.6/distutils/dist.py", line 974 in run_command
    File "/usr/lib64/python3.6/distutils/dist.py", line 955 in run_commands
    File "/usr/lib64/python3.6/distutils/core.py", line 148 in setup
    File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 153 in setup
    File "/root/.local/lib/python3.6/site-packages/numpy/distutils/core.py", line 169 in setup
    File "/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py", line 464 in <module>
    File "<string>", line 1 in <module>

----------------------------------------
ERROR: Command errored out with exit status -11: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9iiorris/mayavi_ce17df6e474c44e9bd05d7c328bb7e02/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-bnbwj46a/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/mayavi Check the logs for full command output.

看了一下网上别人在windows里安装时好像都是使用的比较低版本的vtk,于是我实验了一些低一点版本的vtk,再来组合低一点版本的mayavi,结果发现 vtk 8.1.2  +  mayavi 4.8.0是可以成功安装的,vtk 8.2 + mayavi 4.7.3也可以,反正多试一下找个自己觉得版本算高的就行了。

如果是安装在host上,应该可以用了,如果是安装在docker容器内,运行利用mayavi进行点云可视化之类的程序时很可能还是QT会报错,在~/.bashrc里增加export QT_DEBUG_PLUGINS=1并用source ~/.bashrc生效,再运行程序让QT报出详细错误:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
Cannot load library /usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

类似这样的文件不存在的问题好说,安装就是,用ldd命令查看还缺哪些文件:

ldd /usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so

libxcb-icccm.so.4 => not found
    libxcb-image.so.0 => not found
    *libxcb-util.so.1 => not found
    libxcb-keysyms.so.1 => not found
    libxcb-render-util.so.0 => not found
    libxkbcommon-x11.so.0 => not found

如果你直接安装指定具体版本号后缀了的文件yum install libxcb-icccm.so.4,会导致运行时又这样报错:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
Cannot load library /usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: wrong ELF class: ELFCLASS32)
QLibraryPrivate::loadPlugin failed on "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: wrong ELF class: ELFCLASS32)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

这种wrong ELF class: ELFCLASS32错误表示安装的32位的文件,但是程序需要的是64位的文件,所以需要使用类似这样的命令来选择安装x86_64版的文件:

yum install libxcb-icccm* libxcb-image* libxcb-keysyms* libxcb-render-util* libxkbcommon-x11*

(注意,在不同的docker环境里缺的文件可能有不同,看具体报错情况)

把上面缺的6个文件都安装了后,再运行程序可能又会报这样的错误:

Got keys from plugin meta data ("webp")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/imageformats" ...
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqgif.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqicns.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqico.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqjpeg.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqsvg.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqtga.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqtiff.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqwbmp.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqwebp.so"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/accessible" ...
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
ERROR: In /work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 785
vtkXOpenGLRenderWindow (0x491d930): GLEW could not be initialized.
Segmentation fault (core dumped)

这种错误是当前的容器类没有mesa驱动,用下面的命令安装:

#Centos
yum install mesa*
yum install glut#Ubuntu
sudo apt install mesa-common-dev freeglut3-dev libglfw3-dev libgles2-mesa-dev libglew-dev

再运行程序又报错:

Got keys from plugin meta data ("webp")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/imageformats" ...
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqgif.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqicns.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqico.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqjpeg.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqsvg.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqtga.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqtiff.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqwbmp.so"
loaded library "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/imageformats/libqwebp.so"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/lib64/python3.6/site-packages/PyQt5/Qt5/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/accessible" ...
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
ERROR: In /work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 785
vtkXOpenGLRenderWindow (0x6002f30): GLEW could not be initialized.

Segmentation fault (core dumped)
这是因为当前的容器内没有opengl驱动,一种办法是创建容器是把Host上的cuda和opengl驱动所在目录映射进入容器对应的路径,参见[docker][mayavi] libGL error: No matching fbConfigs or visuals found · Issue #1 · SoonminHwang/dockers · GitHub

另一种是到Docker Hub上选取合适版本的cudgl镜像后直接拉取cudagl镜像来创建容器,例如:

sudo docker pull nvidia/cudagl:11.4.2-devel-ubuntu18.04

我选择后者,后者比较简单,第一种方法比较麻烦。

拉取nvida/cudagl docker image后创建容器:

sudo nvidia-docker run -itd --privileged --pid host --network host --ipc host --name "lddata-nvidia-cudagl-11.4.2-devel" \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw -v /var/run/dbus:/var/run/dbus --device=/dev/dri:/dev/dri -e DISPLAY=$DISPLAY -e QT_X11_NO_MITSHM=1 \
-v /home/fychen/workspace:/workspace nvidia/cudagl:11.4.2-devel-ubuntu18.04 /bin/bash

然后安装python3和pip以及这个镜像里缺少的支持包libsm6,并设置aliyun为pip服务器镜像:

apt-get update
apt-get install python3 python3-pip libsm6
pip3 install --upgrade pippip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/
pip3 config set install.trusted-host mirrors.aliyun.com

再安装mayavi及其所需相关支持包:

pip install numpy==1.19.5 vtk==8.1.2 mayavi==4.8.0 PyQt5 torch==1.9.1

到此,环境安装就完成了!运行调研mayavi将点云可视化的程序即可看到点云图了:

python3 points_visual.py

使用PyCharm安装mayavi相关推荐

  1. 安装mayavi和VTK库的血泪史

    一开始安装VTK库是从官网上下载,但是怎么都找不到whl文件,只有exe文件(vtkpython-7.1.1-Windows-64bit.exe).下载安装之后再PyCharm中import vtk出 ...

  2. pycharm安装pytorch报错 提示系列问题 torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装

    pycharm安装pytorch报错 提示系列问题  torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装 DEPRECATION: The - ...

  3. 7打开pycharm_Python+pycharm安装、关联教程

    1.在Python官网下载Python对应版本:(以WIN10系统,64位为例) Python Releases for Windows​www.python.org 图一 下载链接 2.安装包下载好 ...

  4. python安装方法32位_【Python】pycharm安装32位win7出现的问题解决办法。

    1.安装 PyCharm 是一款功能强大的 Python 编辑器,具有跨平台性,鉴于目前最新版 PyCharm 使用教程较少,为了节约时间,来介绍一下 PyCharm 在 Windows下是如何安装的 ...

  5. python的安装教程-python安装教程 Pycharm安装详细教程

    python安装教程和Pycharm安装详细教程,分享给大家. 首先我们来安装python 1.首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downlo ...

  6. python要不要装pycharm-python安装教程 Pycharm安装详细教程

    这篇文章主要介绍了python的安装教程,和Pycharm的安装详细教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 python安装教程和Pycharm安装详细教程,分享给大家. 首先我们来安 ...

  7. python charm下载安装教程-Python及Pycharm安装方法图文教程

    Python及Pycharm安装方法,供大家参考,具体内容如下 1.任务简介 为了学习Python我今天对它进行了安装,整个安装过程忘了截图,故我在虚拟机中重新安装了一遍,并将Python及Pycha ...

  8. python要不要装pycharm-Python和pyCharm安装

    Python是一种解释型脚本语言,可以应用于以下领域: Web 和 Internet开发 科学计算和统计 人工智能 教育 桌面界面开发 软件开发 后端开发 Python在数据分析.后端开发.人工智能. ...

  9. Pycharm安装pip pip安装第三方模块

    Pycharm安装pip pip-安装第三方组建 打开pycharm → 文件 → 设置 → 项目 → project interpreter,点击"+"加号, 在搜索栏中选择pi ...

最新文章

  1. 50岁马斯克又恋爱了!27岁金发女友长着芭比娃娃脸
  2. 波卡链Substrate (6)Babe协议一“基本概念”
  3. LeetCode 1310. 子数组异或查询(前缀异或)
  4. JavaScript中带有示例的Math.max()方法
  5. SparkStreaming找不到reduceByKey的解决方法
  6. django 1.8 官方文档翻译: 3-3-1 文件上传
  7. 一路风景---我期待的是师生关系
  8. SVG SMIL animation动画详解
  9. Linux 上的数据可视化工具
  10. 数据库系统概论-数据库编程与关系查询处理和查询优化
  11. 基于java五子棋游戏设计与实现
  12. 数学趣话,你知道常见的数学符号都是谁发明的吗?
  13. 日常运维小知识--1
  14. 直立车控制之PID算法分析
  15. 学习spf记录引发的问题(一)
  16. 【听课笔记】复旦大学遗传学_03基因与基因突变
  17. 扬州鉴真国际半程马拉松
  18. 连上hdmi后没有声音。
  19. Shell 的加减乘除
  20. 理解C语言——从小菜到大神的晋级之路(15)——完结篇:C编程风格

热门文章

  1. 输出复杂的菱形(续)
  2. Lost connection to MySQL server during query问题
  3. Python是如何将“中文”转“拼音”的?
  4. springboot项目中访问不到html页面问题
  5. OSChina 周四乱弹 ——程序员要赚多少钱才能让妻子保持温柔和美丽
  6. 人工智能python+dlib+opencv技术10分钟实现抖音人脸变狗头详细图文教程和完整项目代码
  7. 关于子网划分、子网聚合(超网)的研究
  8. 被字句15个_小学语文必考知识:15类句式转换解题方法与练习(附答案)
  9. 如何取消Stadia Pro订阅
  10. 小程序各个文件夹的作用分类