How can I install and import other modules inside pvpython?

I need to import module ‘zmq’. I have tried to run pip but no luck and then get-pip.py with pvpython but it also produce some error. Any help will be really appreciated.

You will need to build ParaView yourself with a python containing the zmq module.

You can use a virtual env along inside pvpython. You can do what we do with our paraview web application here.

1 Like

Thank you for the help. The thing I ended up was clonning the docker image of paraview from the docker hub and in that the enviroment is correctly setuped already and system python and the pvpython behave exactly the same.

Here is a concrete recipe:

first I have installed python with the same version to $HOME directory (not in /usr):

pyver=3.7.4                                                                                         
wget https://www.python.org/ftp/python/${pyver}/Python-${pyver}.tgz                                 
tar xzvf Python-${pyver}.tgz                                                                        
cd Python-${pyver}                                                                                  
./configure --prefix=$HOME/.local                                                                   
make                                                                                                
make install

Then I have renamed the native paraview python and replaced with my version of python (for example my paraview is inside /opt ).

cd /opt/ParaView-5.8.0-MPI-Linux-Python3.7-64bit/lib
mv python3.7 python3.7_
ln -s ~/.local/lib/python3.7 .
P.S. in case of a problem with _bz2 download the appropriate version of .so file as mentioned here and put it in

cp ~/Downloads/_bz2.cpython-37m-x86_64-linux-gnu.so ~/.local/lib/python3.7/lib-dynload/

then your pvpython will use modules of python3.7.
installation of packages is done via

pip3.7 install pandas plotly sklearn --user

the flag --user is important, otherwise new modules will be kept in another place.
Good luck!

It can be done easier:
after installation of appropriate python

pyver=3.7.4
wget https://www.python.org/ftp/python/{pyver}/Python-{pyver}.tgz
tar xzvf Python-{pyver}.tgz cd Python-{pyver}
./configure --prefix=$HOME/.local
make
make install

it needs to define PYTHONPATH as follows:
export PYTHONPATH=$HOME/.local/site-packages

install necessary packages, that is all
BR,
Evgeii