# Cannot import Python modules after having compiled a Python plugin

**URL:** https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622
**Category:** Development
**Created:** [June 16, 2026, 11:16am UTC](https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622 "2026-06-16T11:16:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/csatizoltan/32/6997_2.png) [@CsatiZoltan](https://discourse.paraview.org/u/CsatiZoltan)
#### Post date: [June 16, 2026, 11:16am UTC](https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622/1 "2026-06-16T11:16:44Z")

</div>

I wrote a Python plugin, which imports other custom Python modules (helper modules that I wrote myself). After setting `PYTHONPATH` and then launching ParaView, I can load the plugin successfully and it works as intended.

Now I want to compile the Python plugin. The compilation is successful, but I get an import error when loading the .so file in the Plugin Manager. In my project setup, I mimicked the PythonAlgorithm example. I added a line in [PythonAlgorithmExamples.py](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Examples/Plugins/PythonAlgorithm/Plugin/PythonAlgorithmExamples.py):

```python
import other_module

```

where the content of _other\_module.py_ is simply

```python
# other_module.py
print('Imported "other_module"')  

```

I changed a line in [CMakeLists.txt](https://gitlab.kitware.com/paraview/paraview/-/blob/84f7d7c3c62f86131ec780998a50f47949033954/Examples/Plugins/PythonAlgorithm/Plugin/CMakeLists.txt):

```auto
PYTHON_MODULES PythonAlgorithmExamples.py other_module.py

```

The compilation is successful, but when I load the plugin in ParaView 6.1.1, I get

```auto
Generic Warning: In vtkPVPythonAlgorithmPlugin.cxx, line 235
Failed to load Python plugin:
Failed to call `paraview.detail.pythonalgorithm.load_plugin_from_string`

Traceback (most recent call last):
  File "/home/zc/Programs/ParaView-6.1.1-MPI-Linux-Python3.12-x86_64/lib/python3.12/site-packages/paraview/detail/pythonalgorithm.py", line 546, in load_plugin_from_string
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<not a real path>/PythonAlgorithmExamples.py", line 5, in <module>
ModuleNotFoundError: No module named 'other_module'
Imported "other_module"
Imported "other_module"

```

It is interesting that although I get these import errors, the module is still imported somehow (although the original functionalities of the example plugin do not work).  
When trying without modifications of the `PYTHON_MODULES` line, i.e.

```auto
PYTHON_MODULES PythonAlgorithmExamples.py

```

I get the same error message, but the code in _other\_module.py_ is not executed anymore.

```auto
Generic Warning: In vtkPVPythonAlgorithmPlugin.cxx, line 235
Failed to load Python plugin:
Failed to call `paraview.detail.pythonalgorithm.load_plugin_from_string`

Traceback (most recent call last):
  File "/home/zc/Programs/ParaView-6.1.1-MPI-Linux-Python3.12-x86_64/lib/python3.12/site-packages/paraview/detail/pythonalgorithm.py", line 546, in load_plugin_from_string
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<not a real path>/PythonAlgorithmExamples.py", line 5, in <module>
ModuleNotFoundError: No module named 'other_module'
Generic Warning: In vtkPVPythonAlgorithmPlugin.cxx, line 235
Failed to load Python plugin:
Failed to call `paraview.detail.pythonalgorithm.load_plugin_from_string`

Traceback (most recent call last):
  File "/home/zc/Programs/ParaView-6.1.1-MPI-Linux-Python3.12-x86_64/lib/python3.12/site-packages/paraview/detail/pythonalgorithm.py", line 546, in load_plugin_from_string
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<not a real path>/PythonAlgorithmExamples.py", line 5, in <module>
ModuleNotFoundError: No module named 'other_module'

```

Looking at other examples, I found the [pvblot](https://gitlab.kitware.com/paraview/paraview/-/blob/84f7d7c3c62f86131ec780998a50f47949033954/Plugins/pvblot/CMakeLists.txt#L4-L11) plugin, which uses multiple modules. But that plugin is deactivated, so I cannot build it to try it out.

Do you have an idea why the import does not work when compiled?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 16, 2026, 2:13pm UTC](https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622/2 "2026-06-16T14:13:11Z")

</div>

> [@CsatiZoltan](#):
>
> I found the [pvblot](https://gitlab.kitware.com/paraview/paraview/-/blob/84f7d7c3c62f86131ec780998a50f47949033954/Plugins/pvblot/CMakeLists.txt#L4-L11) plugin, which uses multiple modules. But that plugin is deactivated, so I cannot build it to try it out.

I confirm the pvblot is non-functionnal.

> Do you have an idea why the import does not work when compiled?

I’m afraid you are on your own, I only ever made the example work and did not investigate further.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/csatizoltan/32/6997_2.png) [@CsatiZoltan](https://discourse.paraview.org/u/CsatiZoltan)
#### Post date: [June 16, 2026, 2:21pm UTC](https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622/3 "2026-06-16T14:21:56Z")

</div>

> [@mwestphal](#):
>
> I confirm the pvblot is non-functionnal.

Was it ever functional? I see the same message in the first commit in its history:

```auto
git show cf77c7f76be9f4af9ec29c6f8f73ddddaa5963b9:Plugins/pvblot/paraview.plugin

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 16, 2026, 2:23pm UTC](https://discourse.paraview.org/t/cannot-import-python-modules-after-having-compiled-a-python-plugin/17622/4 "2026-06-16T14:23:48Z")

</div>

At least not since the modularization of VTK, 8 years ago.
