Simply add python modules

Hi everyone.

I’d like to add pyarrow to pvpython so that it can read/write .parquet files.
I managed on my local machine, but had to go through the quite tedious method of building paraview from scratch.

I’d like to know, since I want to share my code using .parquet with others, if there is a more straightforward way?
I did find that using virtual environment could help, as explained here: https://www.kitware.com/using-pvpython-and-virtualenv/

The issue is that I seem to have conflict when I do so using the paraview version from the website. When I build my environment and then use the commands:

vEnv='/home/environments/paraview_env/bin/activate_this.py'
exec(open(vEnv).read(), {'__file__': vEnv})

Then it seems like simple libraries as numpy wont work anymore, with error as such as:

>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/compat/__init__.py", line 18, in <module>
    from pandas.compat.numpy import (
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
    from pandas.util.version import Version
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/util/__init__.py", line 2, in <module>
    from pandas.util._decorators import (  # noqa:F401
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/util/_decorators.py", line 14, in <module>
    from pandas._libs.properties import cache_readonly
  File "/home/boris/environments/paraview_env/lib/python3.10/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
ModuleNotFoundError: No module named 'pandas._libs.interval'

Meanwhile, if I import pandas without the venv, it works… Any clue, or other way of importing my modules?

Thank you!

Not sure that is the issue here but you are using Python 3.10 while ParaView is using Python 3.9.

For your venv you need to have a version match.

Thanks for the idea.

I tried with python 3.9 virtualenv, same issue. And I also get this issue on windows OS.

To use virtual env, is it needed to have a self-compiled version? Or the installer from the website should be enough?

EDIT: Actually, for windows it works. No idea what was wrong the first time. For future readers, what I did is the following:

0- Download and install python 3.9
1- Create a virtualenv and install pyarrow and fastparquet. To do so, use the command like

python -m virtualenv -p="C:\Users\YourPath\AppData\Local\Programs\Python\Python39\python.exe" "Path/to/venv"

2- Then, simply activate the script (.\Scripts\Activate.ps1 for powershell) and install your libraries
3- Now, create an environment variable called PV_VENV, and of value the path to your venv folder.
4- You can check that the venv is indeed used through the python command inside paraview : from paraview.web import venv

Probably the commands from my first post also works, instead of the PV_VENV.

Regarding why it does not work on ubuntu, I will try to look further into it.