Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError #10

Open
ChenHoy opened this issue Oct 15, 2019 · 5 comments
Open

ImportError #10

ChenHoy opened this issue Oct 15, 2019 · 5 comments

Comments

@ChenHoy
Copy link

ChenHoy commented Oct 15, 2019

Hello,
I am trying to use the bindinsg with Python3.7 and boost 1.71.

Both is found during the building process and no warnings or errors are raised. However, when I import orbslam2, I get the following ImportError:
"ImportError: path/to/venv/lib/python3.7/site-packages/orbslam2.so: undefined symbol: _ZN5pbcvt26matToNDArrayBoostConverter7convertERKN2cv3MatE"

The paths to boost has been adjusted in CMakeLists.txt (Boost 1.71 REQUIRED COMPONENTS python37). Everything else was just adjusted to Python 3.7.

Hopefully, someone has an idea why this occurs. This error is similar to Issue #1, but I have explicitly set the paths correctly and the dependencies are apparently found correctly when building.

Thanks in advance for any help!

@danbo2
Copy link

danbo2 commented Nov 10, 2019

Hi @ChenHoy,

Can you help me work the issue out ? I meet the issue after building orbslam2.
Capture

Thanks

@jskinn
Copy link
Owner

jskinn commented Nov 12, 2019

Failure to import like that indicates that python cannot find one of the referenced .so files when importing, even if your compiler could find them when it linked it. Probably one of the boost .so files.
Did you move orbslam2.so after you created it?
You can inspect where orbslam2.so expects to find all it's dependencies by running ldd orbslam2.so. IIRC, these are usually relative paths, so moving the file may break them.
You can add the built orbslam.so to your virtualenv without moving it by using a symlink or a .pth file (see https://docs.python.org/3.7/library/site.html)

@danbo2
Copy link

danbo2 commented Nov 22, 2019

@jskinn Hi, I have compiled successfully in virtual environment, and used a symlink to add the built orbslam2.so to the virtualenv and checked dependencies are well. However, I am not luck to import it successfully. Can you help me solve the issue ?
SLAM
Link
Thanks

@jskinn
Copy link
Owner

jskinn commented Dec 18, 2019

A couple of issues:

  • You've misspelled '$PYTHONPATH' in '/home/yxie/ORB_SLAM2/ORBSLAM2-PythonBinding/Examples/$PATHONPATH'. I'm not sure what you're trying to do there.
  • That set of sys.path paths don't look like a virtualenv, they reference the system python location.
  • You're going to need the relevant dependencies, particularly numpy.
  • What is the output when you try and import? if it's says something about being unable to find module orbslam2, then your symlink is in the wrong place.

@Braz3n
Copy link

Braz3n commented Mar 17, 2020

This issue can also be caused if you're trying to build the project with OpenCV4 instead of OpenCV2 or 3.

Unfortunately the ORB_SLAM2 repository isn't compatible with OpenCV4 either. You can use this fork of the original repo to build under OpenCV4, however.

As far as this project is concerned, only a couple changes are needed to work with the aforementioned fork:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants