mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.3k stars 848 forks source link

ImportError: No module named 'extract_metadata' #92

Open nevrome opened 7 years ago

nevrome commented 7 years ago

I tried to setup OpenSfM today in my Arch Linux environment. Unfortunatly I get the following error when running bin/run_all data/berlin:

Traceback (most recent call last):   
File "/home/clemens/libraries/OpenSfM/bin/opensfm", line 10, in <module> from opensfm import commands   
File "/home/clemens/libraries/OpenSfM/opensfm/commands/__init__.py", line 2, in <module> import extract_metadata   
ImportError: No module named 'extract_metadata'

Could you please point me to the right direction to solve this?

paulinus commented 7 years ago

There seem to be a problem with the python path. /home/clemens/libraries/OpenSfM/ should be on the python path for python to find the opensfm modules. Normally, this is done automatically by the opensfm command here. For some reason it seems not to be working on your environment.

Can you try adding the path manually using something like

export PYTHONPATH=$PYTHONPATH:/home/clemens/libraries/OpenSfM/`
nevrome commented 7 years ago

The python path seems to be correct now:

[clemens@clemens_asus OpenSfM]$ python2
Python 2.7.12 (default, Jun 28 2016, 08:31:05) 
[GCC 6.1.1 20160602] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/home/clemens/libraries/OpenSfM', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gtk-2.0']

Unfortunately the problem remains the same.

paulinus commented 7 years ago

is this still an issue for you @nevrome ?

nevrome commented 7 years ago

Yes. Just pulled the latest version, ran the building commands and tried to start the calcultation with bin/run_all data/berlin. Still the same error.

paulinus commented 7 years ago

Sorry to hear. We did not see that happening anywhere else. Can you think of something that would be different on your setup? Is /usr/bin/env python running python 2 or 3 for you?

nevrome commented 7 years ago

/usr/bin/env python calls python 3 and /usr/bin/env python2 calls python 2.

paulinus commented 7 years ago

So this must be the problem. OpenSfM works on python 2, but the python command on your system launches python 3. You can make it work on your side by changing this line

nevrome commented 7 years ago

Ah - ok. That works. The next error when I call bin/run_all data/berlin:

Traceback (most recent call last):
  File "/home/clemens/libraries/OpenSfM/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/home/clemens/libraries/OpenSfM/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/home/clemens/libraries/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/home/clemens/libraries/OpenSfM/opensfm/dataset.py", line 12, in <module>
    from opensfm import io
  File "/home/clemens/libraries/OpenSfM/opensfm/io.py", line 10, in <module>
    from opensfm import features
  File "/home/clemens/libraries/OpenSfM/opensfm/features.py", line 7, in <module>
    import csfm
ImportError: /home/clemens/libraries/OpenSfM/opensfm/csfm.so: undefined symbol: cs_di_ltsolve

My first guess was a missing dependency, but I can't find anything.

Maybe I should open a new issue for this? But maybe the problems are somehow related...

paulinus commented 7 years ago

This looks like an error with Ceres' dependencies. Someone here had a similar problem. Could that be related to your problem?

whizzzkid commented 6 years ago

Just leaving this here for future reference. Use the following build flags for ceres-solver:

$ git clone https://ceres-solver.googlesource.com/ceres-solver
$ mkdir ceres-solver/build
$ cd ceres-solver/build
$ cmake \
      -D CMAKE_C_FLAGS="-fPIC" \
      -D CMAKE_CXX_FLAGS="-fPIC" \
      -D BUILD_EXAMPLES=OFF \
      -D BUILD_SHARED_LIBS=ON \
  ..
$ make -j $(($(nproc)+1))
$ make test
$ sudo make install