try import in extract_selection.py masking an incompatible numpy build error, causing confusion
I have a paraview 5.1 installation on Ubuntu where I also have an installation of numpy from pip (pip install numpy
). I believe the build installed via pip is a pre-built version via the new wheel system (not sure if this is correct as I'm not too familiar with that system).
When I try to use the Find data feature in paraview, running a selection query will return:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 2, in vtkPythonExtractSelection_RequestData
File "/home/shuhao/apps/paraview/lib/paraview-5.1/site-packages/paraview/extract_selection.py", line 10, in <module>
raise RuntimeError, "'numpy' module is not found. numpy is needed for "\
RuntimeError: 'numpy' module is not found. numpy is needed for this functionality to work. Please install numpy and try again.
This is strange, as I can clearly see numpy available in my paraview installation. I dug into that file, and then removed the try: block and then see the following error being returned:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 2, in vtkPythonExtractSelection_RequestData
File "/home/shuhao/apps/paraview/lib/paraview-5.1/site-packages/paraview/extract_selection.py", line 7, in <module>
import numpy as np
File "/home/shuhao/.local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/shuhao/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/shuhao/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/shuhao/.local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/shuhao/.local/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: /home/shuhao/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
Clearly, it seems that the import tried to import my installed numpy installation rather than the paraview bundled one, which seems to be causing some sort of issues from within paraview only (doesn't seem to happen when I use my numpy installation normally).
The error message made the situation that much more confusing, as it is suggesting me to do something that's not the root cause here.
I believe this can be fixed either by removing that try block all together, or somewhere else in paraview, reorder sys.path such that the paraview paths are always first and thus picked first.
For me personally, I simply uninstalled my numpy version and all is well.