ORB_SLAM2-PythonBindings icon indicating copy to clipboard operation
ORB_SLAM2-PythonBindings copied to clipboard

Install under python3 virtualenv

Open yizhou-wang opened this issue 6 years ago • 2 comments

Can this package installed under python3 virtual environment? I tried to run the following command in cmake:

cmake .. -DCMAKE_INSTALL_PREFIX=/home/xxx/venv

But ImportError appears:

ImportError: No module named 'orbslam2'

Is there a way to install orbslam2 in Python3? Thank you!

yizhou-wang avatar Sep 12 '18 03:09 yizhou-wang

Yes - I got it working in a Python 3 virtual environment after adding the path specified in cmake to PYTHONPATH:

export PYTHONPATH=/home/xxx/venv:$PYTHONPATH

lefthandwriter avatar Oct 10 '18 20:10 lefthandwriter

Python looks for modules within the /home/xxx/venv/lib/python3.5/site-packages directory of the virtual environment, rather than the root (/home/xxx/venv/), so you'd need to point the install prefix there.

Rather than trying to install to the virtual environment, my usual approach is to install to some subdirectory of the repository (say, /opt/ORBSLAM2-PythonBindings/install), and then add that to the virtual environment using a orbslam.pth file in /home/xxx/venv/lib/python3.5/site-packages. Just make a file in that directory with the .pth extension, and containing only the path /opt/ORBSLAM2-PythonBindings/install (or wherever you installed it). See https://docs.python.org/3.6/library/site.html This makes it easy to use one installation of the bindings in many virtual environments.

jskinn avatar Jun 03 '19 03:06 jskinn