Importing Paraview Module in Python 3.7/3.8

Hello,

I have a python script that I’m attempting to run in Spyder (Python 3.7).
On a line that tries to import Paraview that says:
“from paraview.simple import *”
An error occurs that says:
“No module named ‘paraview’”

How can I go about importing the Paraview module into my Spyder IDE? If that’s not possible, how can I import Paraview into my command line Python script?

Thanks.

I think you should use pvpython instead of Python

Assuming your Python versions between ParaView and Spyder builds are ABI compatible, here’s a way to figure things out.

Run pvpython with following code

import sys
print sys.path

The sys.path will begin with a couple of ParaView related directories. Add those to your sys.path in your script for Spyder (or PYTHONPATH environment variable).

On linuxs generally, that’s adequate. On Windows/Mac, you may need to extend you PATH/DYLD_LIBRARY_PATH to include the directory where a the ParaView dylibs or dlls are as well.

1 Like

Just a note for people who might still have issues after messing with sys.path.

I had issues when I added those paths to PYTHONPATH. All of my Anaconda apps (Spyder, Anaconda Navigator, etc.) could not open - I think setting PYTHONPATH confused the apps for where to look for Python. Something along those lines.

Instead, I added them to my PATH variable and I only included the site-packages folder path in PYTHONPATH. That way I could still use Anaconda and use the simple module.