I’m facing an undefined symbol: Py_Main
error upon entering command import vtk
to Blender Python Console. This error does not occur when executing same command from Blender’s python3.9
executable, so I wonder what could be wrong.
Long story
Using off-the-shelf blender-2.93.5-linux-x64.tar.xz
. I need vtk
Python module in Blender, which I’ve installed to Blender’s Python environment by commands
cd blender-2.93.5-linux-x64/2.93/python/bin
./python3.9 -m ensurepip
./python3.9 -m pip install vtk==9.0.3
When I start up blender --factory-startup
, go to Blender Python Console and issue the command, I get this error:
>>> import vtk
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/home/x/blender-2.93.5-linux-x64/2.93/python/lib/python3.9/site-packages/vtk.py", line 30, in <module>
all_m = importlib.import_module('vtkmodules.all')
File "/home/x/blender-2.93.5-linux-x64/2.93/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/x/blender-2.93.5-linux-x64/2.93/python/lib/python3.9/site-packages/vtkmodules/all.py", line 48, in <module>
from .vtkRenderingMatplotlib import *
ImportError: /home/x/blender-2.93.5-linux-x64/2.93/python/lib/python3.9/site-packages/vtkmodules/libvtkPythonInterpreter-9.0.so: undefined symbol: Py_Main
However, if I run the same import command in python executable blender-2.93.5-linux-x64/2.93/python/bin/python3.9
, the module loads without errors. Any idea what’s the cause?
Same error occurs with vtk==9.0.2
and blender-2.93.0-linux-x64.tar.xz
. However, this used to work without problems in Blender 2.83 series with vtk==9.0.1
. Something changed in Python or Blender?