Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#74455 - [paraview] pvpython cannot import non-standard-library system modules (e.g. matplotlib, PIL)

Attached to Project: Community Packages
Opened by Jakub Klinkovský (lahwaacz) - Tuesday, 12 April 2022, 14:12 GMT
Last edited by Bruno Pagani (ArchangeGabriel) - Saturday, 23 July 2022, 19:29 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Bruno Pagani (ArchangeGabriel)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Since the paraview-wrapper script was introduced, importing non-standard-library Python modules in pvpython does not work. For example, matplotlib:

$ pvpython -c "import matplotlib"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'

Adding the /usr/lib/python3.10/site-packages path explicitly to PYTHONPATH seems to fix the issue:

$ export PYTHONPATH=/usr/lib/python3.10/site-packages
$ pvpython -c "import matplotlib"

This should be solved in the paraview-wrapper script. When matplotlib is not available in pvpython, various rendering issues may appear, e.g. https://gitlab.kitware.com/paraview/paraview/-/issues/21352 (that is probably direct consequence of this bug)
This task depends upon

Closed by  Bruno Pagani (ArchangeGabriel)
Saturday, 23 July 2022, 19:29 GMT
Reason for closing:  Fixed
Additional comments about closing:  paraview 5.10.1-9.
Comment by Bruno Pagani (ArchangeGabriel) - Wednesday, 13 April 2022, 21:22 GMT
OK, noted. I guess we can have the two paths under PYTHONPATH and that there is a priority inside this just like PATH so that an eventual vtk installation does not get called for modules also in paraview.
Comment by Jakub Klinkovský (lahwaacz) - Thursday, 14 April 2022, 08:53 GMT
Indeed, the /opt/paraview/lib/python3.10/site-packages path should be prepended and /usr/lib/python3.10/site-packages appended. The binaries pvpython and python set the default sys.path as follows:

/opt/paraview/bin/pvpython -c "import sys; print(sys.path)"
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload']

$ python -c "import sys; print(sys.path)"
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/lahwaacz/.local/lib/python3.10/site-packages', '/usr/lib/python3.10/site-packages']

The difference seems to be due to the 'site' module: https://docs.python.org/3.11/library/site.html
When I run python -S, the sys.path becomes the same as that of pvpython:

$ python -S -c "import sys; print(sys.path)"
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload']

To get the same sys.path (almost) in pvpython as in default python, I need to

$ /opt/paraview/bin/pvpython -c "import site; site.main(); import sys; print(sys.path)"
['/home/lahwaacz', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/lahwaacz/.local/lib/python3.10/site-packages', '/usr/lib/python3.10/site-packages']

It seems that for some reason pvpython behaves as if the -S flag was specified. Also note that the same goes for vtkpython (from the vtk package) so it might be an upstream issue.
Comment by Jakub Klinkovský (lahwaacz) - Thursday, 14 April 2022, 09:03 GMT
I've submitted an upstream issue for vtkpython, maybe we will learn more: https://gitlab.kitware.com/vtk/vtk/-/issues/18518
Comment by Bruno Pagani (ArchangeGabriel) - Friday, 01 July 2022, 13:01 GMT
I’ve backported the vtk changes into paraview 5.10.1-9, currently in [community-staging] due to proj/gdal rebuild. Will update again once moved to [testing].
Comment by Bruno Pagani (ArchangeGabriel) - Friday, 01 July 2022, 13:01 GMT
(And I’ll upgrade vtk to 9.2 during the rebuild normally, so that should fix it)
Comment by Bruno Pagani (ArchangeGabriel) - Friday, 01 July 2022, 15:59 GMT
Actually vtk 9.2 is not released yet (only rc), so I’ve backported the patch into vtk 9.1.0-19 (currently in [community-staging] as well).
Comment by Bruno Pagani (ArchangeGabriel) - Friday, 22 July 2022, 13:56 GMT
Please test paraview 5.10.1-9 and vtk 9.1.0-19.
Comment by Jakub Klinkovský (lahwaacz) - Saturday, 23 July 2022, 17:25 GMT
It's fixed, thanks for backporting the patches.

Loading...