Issues with numpy with built version of ParaView

Hi,

I’m building ParaView (I get the same issue with VTK) and when I run pvpython I can’t import numpy. I can import numpy using my system Python, which my ParaView is built against. It looks like it’s my Python sys.path which is confused, possibly due to a non-standard install location of MPI. When I run pvpython this is what I get:

[acbauer@dsrclxerd5621m debug]$ bin/pvpython 
Python 3.6.8 (default, Jan 11 2023, 08:43:50) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/acbauer/Code/ParaView/debug/lib64/python3.6/site-packages', '/usr/local/mpich/usr/lib64/python36.zip', '/usr/local/mpich/usr/lib64/python3.6', '/usr/local/mpich/usr/lib64/python3.6/lib-dynload', '/usr/local/mpich/usr/lib64/python3.6/site-packages', '/usr/local/mpich/usr/lib/python3.6/site-packages']
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

When I just run Python, i.e. Python 3.6.8, I get the following:

[acbauer@dsrclxerd5621m debug]$ python3 --version
Python 3.6.8
[acbauer@dsrclxerd5621m debug]$ python3
Python 3.6.8 (default, Jan 11 2023, 08:43:50) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages']
>>> import numpy

If I add [‘’, ‘/usr/lib64/python36.zip’, ‘/usr/lib64/python3.6’, ‘/usr/lib64/python3.6/lib-dynload’, ‘/usr/lib64/python3.6/site-packages’, ‘/usr/lib/python3.6/site-packages’] to my sys.path for pvpython everything works fine (see below). Any hints on how to change my ParaView (and VTK) build to include the proper sys.path for numpy?

[acbauer@dsrclxerd5621m debug]$ bin/pvpython 
Python 3.6.8 (default, Jan 11 2023, 08:43:50) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path = sys.path + ['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages']
>>> import numpy
>>> 

Thanks,
Andy

ParaView packages “bring” their Python environment with them. While it may use your system libraries, pvpython is going to act like the root of its own Python distribution.

On the other hand, there are some oddities here. Such as why /usr/local/mpich shows up… Some debugging of site.py may be necessary to learn how the default paths are being built up here. Is there some loaded module interfering perhaps?

Thanks for the reply. My os.path under pvpython was pointing to a location that was relative to my mpich install that was in a non-standard location. I think that install brought in a bunch of other things that caused some issues. Once I got my os.path issue fixed things were working as desired.