Not able to import paraview.simple module on windows

Hello everybody,

My first post here. I first asked my question here on StackOverflow, and then I was told to come here. To solve my own problem I’m trying to follow this documentation. According to that page I have to add these two folders to my PATH:

  1. C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib
  2. C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\site-packages

I also have Python Python 3.6.5 installed. But when I run the Python shell ant tryo to import paraview.simple with

from paraview.simple import *

I get the error message:

Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘paraview’

I would appreciate if you could help me know what is my mistake and how I can solve it.

I think you need to set the PYTHONPATH environment variable too, so that Python knows to look there. PATH is for the Windows dll loader. You need this one too, so that it finds the ParaView dlls that the python interface depends on. But PYTHONPATH tells python where to look. You can see the folders Python is searching for modules by running this:

import sys

Check to make sure python is looking in the folders you listed.

Another problem is that you aren’t using the same version of Python as ParaView. ParaView’s installer packages from the website uses Python 2.7 and you are trying to use Python 3.6. That can’t ever work (but it should give a different error message if this was the problem you were hitting).

1 Like

Thanks for your immediate reply. two questions:

  1. should I create a new system variable and add two addresses above as suggested here? I did this and got the error below when trying to run Python:

Fatal Python error: Py_Initialize: unable to load the file system codec
File “C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\”, line 123
raise CodecRegistryError,
SyntaxError: invalid syntax

Current thread 0x000032ec (most recent call first):

I tied adding the python executable path C:\Users\foobar\AppData\Local\Programs\Python\Python36-32 too, as suggested here, but I still get the same error message.

  1. when I run import sys; print(sys.path) in my shell I get:

[’’, ‘C:\Users\foobar\AppData\Local\Programs\Python\Python36-32\’,

I think I have to add the paths above here instead? Where are these paths stored?

To answer 1:

This is the error generated by Python 3.6 when trying to run a Python 2.7 python file. Although it shouldn’t be trying to load that particular file. Let me try to outline how I would set up the environment (disclaimer: I don’t have time to reboot into Windows, so this is not tested here).

I believe the only folder you need to add to your PYTHONPATH environment variable is this one:

C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\site-packages

you may need this one too… I’m not sure:

C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin

And you need some combination of these in your PATH environment variable:

C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\site-packages
C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin
C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib

The last one you probably don’t need.

But due to the Python version difference you will need to get Python 2.7 in order to work with ParaView’s python packages unless you build ParaView yourself and link against Python 3.6.

1 Like

To answer 2:
Those paths come from within Python. In addition to those default paths, any paths in the PYTHONPATH environment variable will be added to this list. When it gave that error, it was trying to pull in some of Python’s builtin code that we ship with ParaView, but because we ship the Python 2.7 version it failed to load the file. If it had gotten past the error, printing out sys.path would have included the ParaView paths you added to the PYTHONPATH.

1 Like

Ok. So I think I have to install Python2.7. but my issue is that if I add those paths above to PYTHONPATH it will affect my python 3.* installation. is there any way to seperate the PYTHONPATH for different versions of Python. I was hoping question 2 above would lead a to a solution for this issue, where I can edit the file import sys; print(sys.path) is referring to locally.

I don’t know of a way to set a Python version specific PYTHONPATH.

I don’t know how you are running Python, but if you are running it from a command prompt/powershell you could set the environment variable locally (in the shell) rather than globally for your user.

Alternatively, you could try not setting PYTHONPATH at all and doing this before you try to import paraview:

import sys
sys.path.insert(0, 'C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\site-packages')

Basically this is editing Python’s list of folders to search from within Python. All I can say for this method is that I have occasionally used it before when testing things and it may not always work. You still need your PATH set correctly though to find the dlls.

1 Like

Nope! latest python 2.* is installed now. I tried the sys.path.insert ... command you gave above it did not work. I also tried adding the paths above to a .pth file in C:\Python27\Lib\site-packages as suggested here. It did not work either :disappointed_relieved:

Solved the problem. adding the path:

 C:\Program Files\ParaView 5.4.1-822-g597adef-Qt5-Windows-64bit\bin\Lib\site-packages

to a .pth file in C:\Python27\Lib\site-packages solves the problem. I think these instructions worth mentioning in the tutorial page.

P.S. Although the import problem is initially solved later when I want to render things I get no responding VTK window as described here.

@foadsf It is much easier to get started with Python scripting for ParaView by using the pvpython.exe program that comes with ParaView. pvpython.exe is essentially python2.7 with all the needed paths set up in PATH and PYTHONPATH. If you don’t want to use pvpython.exe for some reason, you can at least run it to see what the environment variables should be, though it looks like with @shawn.waldon’s help you got it figured out.

1 Like

I did not know of pvpython.exe. Thanks. I will look into that. My initial problem with from paraview.simple import * seemed to be resolved, however I got stuck with another problem as I have explained here. Non responding VTK window!

@cory.quammen I was trying to test the other issue on my mac to see if the same happens. It is even worse! I figured out that if I put the .pth file in the /usr/local/lib/python2.7/site-packages folder it will be added to the PYTHONPATH. But right from there is all errors:

Error: Could not import vtkCommonComputationalGeometry
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/Applications/”, line 41, in <module>
from paraview import servermanager
File “/Applications/”, line 53, in <module>
from paraview import vtk
File “/Applications/”, line 12, in <module>
all_m = importlib.import_module(‘paraview.pv-vtk-all’)
File “/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/”, line 37, in import_module
File “/Applications/”, line 7, in <module>
from vtkmodules.vtkCommonCore import *
File “/Applications/”, line 9, in <module>
from vtkCommonCorePython import *
ImportError: No module named vtkCommonCorePython

The is in the /Applications/ folder but adding it to the .pth file just causes more errors.

I haven’t checked the pvpython.exe but is there an equivalent on mac?

Yes, it is called pvpython and it is located in /Applications/ParaView-X.X.X/Contents/bin/.

It is worth your time at least skimming Chapter 1 of the ParaView Guide which gives a good overview of the ParaView suite of tools. Python scripting examples are provided in many places throughout the guide as well.

1 Like

@cory.quammen I have the PDF actually, but it is a bit verbos for my short attention span :grinning: plus copy pasting code and other PDF issues.
I googled paraview+python and found these ParaView’s Python documentation!. Maybe it would be a good idea to add some TL;Dr versions on those pages.

To see if I have understood the topic of ParaView Python interactions I have made this graph:

Apparently the relationship is very complicated. There are 4 different ways to run Python commands. Using a normal Python 2.* interpreter which requires all the PYTHONPATH settings as described in this page. However pvpython and pvbatch are python interpreters coming with ParaView installation with all these settings preset. The other option is to use the Python Shell panel inside the ParaView GUI. Just go to Menu>View>Python Shell. To run a whole python script at once you can go to Menu>Macros>Add new macro>

There are also two different ways to visualise the commands. One is through VTK using Render()/Interact() commands. The other, and IMO preferred option is to use a multi-client ParaView server as described here.

One suggested way to write ParaView Python scripts is to first run the desired steps through GUI and record them in Python. To do so you should go to Menu>Tool>Trace before the steps you want to record and stop it from the same place when you are done.

That’s not entirely correct. I think of it as the following. Hopefully, that may help.

There are two programming modes available in Python: (a) one for writing data processing code and another for building (b) visualization pipeline.

In (a), you’re implementing the guts of a data filter or generator such as a Clip filter, or a Slice filter etc. Here, you are directly manipulating data. Typically, this is done in a Programmable Source / Filter. Here, you’re directly writing VTK-Python script.

In (b), you’re building the visualization pipelines i.e. connect filter A to B, showing its result in View C, etc. pvpython/pvpbatch/Python Shell in GUI, Python Macro, Trace, all are operating in this environment. In pvpython, you don’t have an active event loop running in the background. So, to start and event loop to respond to mouse events, you can use the function Interactor. In the Python Shell, you don’t need that since the Qt application has an event loop that can handle your mouse events just fine.

There’s no difference between using external Python interpreter/terminal or pvpython except that pvpython sets up sys.path so that all ParaView specific Python modules are found.

BTW, some of these aspects are explained in the ParaView Guide as well, so I’d recommend giving it a glance, if you haven’t already.

If I might add, as well you could just do a

conda install paraview

and then in the conda environment

import paraview.simple

paraview binary packages in conda-forge I believe are available for windows, osx and linux as well. And since the python version in this paraview uses the one in the conda environment, you can readily import external python packages in paraview python shell, programmable sources or filters.

Hi @Mohamed_Abdelkhalek: Did conda install work for you?

When I am trying, I am getting below error message and kind of stuck


sadly, this apparently only works on linux. Neither mac os or windows, fail for different reasons.

My recommendation is the following, and this is actually what I do now regularly. Based on the following example.

Making pvpython use your python env

i.e create a virtual env with your python (whatever it is through conda, pyenv, pipenv). I use pipenv


Then once you create the virtual env and install any packages you want (just make sure the python version matches that of Python (currently 3.8.6). You will find a script file in .venv folder that the first link talks about, change the path accordingly)

I believe in windows it is in .venv/Scripts/, then in Paraview just run that script as a macro or through the python shell.

Now, in paraview python shell.

import *my_package*

Should work normally.

I’m a master student and I’m facing the same problem in terms of import just the paraview.simple module. I tried to use the pip as I did with all the other libraries that I want. The error message is “ERROR: Could not find a version that satisfies the requirement paraview.simple (from versions: none)
ERROR: No matching distribution found for paraview.simple”.
My purpose to use paraview to create a good 3D view of aggregates in proteins. I’m doing my own code in order to analyze the size and everything but so far I’m struggling with just create a good 3D view of the matriz that I already have.

Coming to the topic, I tried to understand and I’m still learning how to use the paraview at my favor.
Hope to hear some good