I just pulled the latest version of opencv from source, and unfortunately for the moment I must have 2 different versions on one machine.
So I have the default location /usr/local/...
for the older version, and a custom location for the newer version.
My issue is that if I open a python terminal and try to import cv2
, I can only get the new version to load if I start in the opencv/lib
directory of the new version.
I want to be able to toggle which version of opencv I use, ideally it would be in the python script itself.
I expected to be able to set either LD_LIBRARY_PATH
or PYTHONPATH
or both in the terminal, or change the environment variables using os.environ
, but had no success.
First, I don't understand why I have to be in the lib
directory to get the new version to load, and second I don't see why I cannot dynamically change where python looks to import the module using environment variables.
Any help is appreciated.