vtkpython does not run 'site.main()' upon initialization
The sys.path
after vtkpython's default initialization is incomplete:
$ vtkpython -c "import sys; print(sys.path)"
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload']
Comparing with the python3.10 interpreter:
$ python3.10 -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']
To get the same sys.path
in vtkpython (well, almost - except for the current working dir), I need to run site.main():
$ vtkpython -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 appears that vtkpython initializes sys.path
as if the -S
flag was always given. Is there a reason for this? The current behavior prevents vtkpython from importing modules from the system and user's site-packages directories.
This was tested on Arch Linux with vtk-9.1.0-13.
Edited by Jakub Klinkovský