install other Python modules

Hello, I’m trying to bring this past project (http://www.mathcancer.org/blog/paraview-for-physicell-part-1/) in line with the latest ParaView (5.10.1). I’m starting out on macOS 12 (arm64), but will eventually want it for Windows (and possibly Linux) too. For starters, I see that 5.10.1 comes with an embedded Python (pvpython 3.9.5). Is it possible to (easily) install an additional module, e.g., scipy, that is not already installed?

I saw this post from ~3 yrs ago (by a student in our lab) which asked the same question, for Windows: ParaView - Scipy Module
There didn’t seem to be a very clear answer then, so I wondered if things have changed with 5.10.

thanks!
Randy

Not easily with the binary package. Simple if you build ParaView yourself.

@jourdain

You can use a Python venv to add any additional Python package to ParaView. You just need to import paraview.web.venv and have the path to your venv exported to an environment variable PV_VENV.

Note: Your venv must be built from the same version of Python that is used inside Paraview.

1 Like

I appreciate the replies! I don’t typically work with venv (and more importantly, our users don’t), but does this therefore require that I would need to manually install the Python version that matches that used by PV (and then create a venv using it)? We already essentially require our users to install the very large Anaconda distribution, which will likely not be the same Python version as PV’s. If this additional, somewhat redundant install is necessary, then it may be preferable to opt for a different workflow, like ask them to convert all their .mat formatted files to .vtk (with a script we would provide).

I mean, you could technically enable your anaconda within ParaView assuming your anaconda use Python 3.9.

Sorry, what exactly do you mean by “enabling anaconda within PV”? My current Anaconda distro is at 3.8.8, but maybe there’s been an upgrade.

What I’m saying is that with the same infrastructure I was mentioning before, you can make ParaView access your full Anaconda environment with the caveat that they share the same Python version 3.x.y where X needs to match but not Y. Also because Anaconda will have some native code base, it is possible that some of them won’t work properly within ParaView but you will only know which one, once you try.

So for your use case, you will either need to upgrade your Anaconda to 3.9 or build a ParaView using the Python from Anaconda which will then make it fully compatible.

I hope that clarify what I mean.

1 Like

Thanks very much! It seems to be working for me now, after installing an Anaconda 3.9.x distro and following your advice. I really appreciate your help.

I am not managing to make this work. I am using Widnsos, and my ParaView Python and Anaconda Python are 3.9.5 and 3.9.12, respectively. I have set the environment variable PV_VENV to the anaconda main directory (C:\Users\rudolf.hellmuth\Anaconda3), and run:
>> from paraview.web import venv
ParaView is using venv: C:\Users\rudolf.hellmuth\Anaconda3

>>> import scipy

Traceback (most recent call last):

File “”, line 1, in

ModuleNotFoundError: No module named ‘scipy’

>>> import numpy
>>> numpy.file

‘C:\Program Files\ParaView 5.10.1-MPI-Windows-Python3.9-msvc2017-AMD64\bin\Lib\site-packages\numpy\init.py’

Although venv has found the PV_VENV, is is neither finding scipy nor importing anaconda’s numpy. Could you please tell me what else is missing here?

Are you sure C:\Users\rudolf.hellmuth\Anaconda3 is the location of your anaconda venv that you want to use?

Hi Sebastien,

It is the path I get when I type “conda env list” on the anaconda terminal…

Best regards,
Rudolf

I guess I’m not sure what could be going on for the scipy part. By default, packages from paraview will be loaded first since you run from pvpython and not python.

Then maybe with scipy you have compiled dependencies to core python which might make it incompatible with pvpython which could prevent its loading.

For compiled python dependency, you really need to be based on the exact same python. Which means, you should probably build ParaView against your anaconda python so you could embed your ParaView into your anaconda.

I haven’t built my paraview. I downloaded the binary installer. I had thought paraview.web.venv would link my pvpython to any python module installed in the venv, as long as the python version is the same for the first and second number (i.e., a module of python x.y.a would work with pvpython x.y.b).

Is there anything I’ve misunderstood?

Your understanding is correct with a caveat/limitation.

The limitation is that some python module are actually controlling native code that are linked with the core of Python. In such case, they became incompatible between the Python from ParaView regardless of the version because such python is built with different flags.

But for all the plain python ones and native that don’t link against Python they should work without issue.

1 Like

Ow, damn… :frowning:

I had a script with scipy running on a linux machine, which I wanted to run again. I guess the only solution would be to build ParaView myself, isn’t it?

most likely and you will have to build PV against that specific python. But that could be done without the superbuild which could be easier. Then just properly set your PYTHONPATH and PATH so the PV libs gets found from your Python (system/anaconda).

1 Like

Thank you, I will do that!

Best regards