sys.path ordering problem - ParaView directories are listed last
There have been a couple reports on the mailing list of ParaView putting its path last in sys.paths
:
Paraview used the correct python executable, but the pythonpath was incorrect. vtk.file showed a path to the anaconda python folder. I had an environment variable pythonpath set for anaconda, and in paraview these paths were at the beginning of
sys.path
. I removed the environment variable and everything works fine. Could it be possible to add the paraview python paths at the beginning ofsys.path
?
and:
I've encountered a minor, but annoying issue (for me, at least) when using Python in Paraview (installed from binaries on Windows). I noticed that since version 5.2, the Paraview-related paths are appended to the end of the system PYTHONPATH variable, instead of inserted at the beginning. For instance:
v5.1.2
>>> import sys
>>> for p in sys.path:
... print p
...
D:\Program Files\ParaView 5.1.2\lib\paraview-5.1\site-packages\vtk
D:\Program Files\ParaView 5.1.2\lib\paraview-5.1\site-packages <- Paraview VTK code
D:\Program Files\ParaView 5.1.2\lib\paraview-5.1
D:\Program Files\ParaView 5.1.2\bin
...
D:\Anaconda2\Lib\site-packages <- original system PYTHONPATH paths
etc...
D:\Program Files\ParaView 5.1.2\bin\python27.zip
D:\Program Files\ParaView 5.1.2\bin\DLLs
D:\Program Files\ParaView 5.1.2\bin\lib
D:\Program Files\ParaView 5.1.2\bin\lib\plat-win
D:\Program Files\ParaView 5.1.2\bin\lib\lib-tk
D:\Program Files\ParaView 5.1.2\bin
D:\Program Files\ParaView 5.1.2\bin\lib\site-packages
v5.4.0-RC2:
>>> import sys
>>> for p in sys.path:
... print p
...
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin
...
D:\Anaconda2\Lib\site-packages <- original system PYTHONPATH paths
etc...
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\python27.zip
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\DLLs
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib\plat-win
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib\lib-tk
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib\site-packages <- Paraview VTK code
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib\site-packages\win32
D:\Program Files\ParaView 5.4.0-RC2-Qt5-OpenGL2-Windows-64bit\bin\lib\site-packages\win32\lib
This is a problem for me because I like to use the Python Programmable Filter a lot, but now whenever I import VTK, it will first look for the version of VTK on my system, rather than the one used by Paraview, which leads to conflict errors.
I know this can be fixed by running the Python Shell and manipulating the PYTHONPATH variable from there, but I'd have to do that every time I open Paraview, which is pretty cumbersome. Is there a way to change this behavior? Could it be a changed back in future versions or was there a reason for this change?