mapillary / OpenSfM

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

RuntimeError: module compiled against API version a but this version of numpy is 9 #79

Closed slightHYP closed 7 years ago

slightHYP commented 8 years ago

Dear all,

I followed all the instructions to compile and build OpenSfm, but now I'm stuck at the last step.

If I run the command: bin/run_all data/berlin

It gives me the following error:

RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
  File "/Applications/XAMPP/htdocs/OpenSfM-master/OpenSfM-master/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/Applications/XAMPP/htdocs/OpenSfM-master/OpenSfM-master/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/Applications/XAMPP/htdocs/OpenSfM-master/OpenSfM-master/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/Applications/XAMPP/htdocs/OpenSfM-master/OpenSfM-master/opensfm/dataset.py", line 10, in <module>
    import cv2
ImportError: numpy.core.multiarray failed to import

I downgraded numpy from 1.11.0 to 1.9.3 but nothing changed.

Any advice is more than welcome ;-)

I'll paste here the python setup.py build log:

Configuring...
-- Try OpenMP C flag = [-fopenmp=libomp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [ ]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-Qopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-xopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [+Oopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-qsmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-mp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-fopenmp=libomp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [ ]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-Qopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-xopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [+Oopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-qsmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-mp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Could NOT find OpenMP (missing:  OpenMP_C_FLAGS OpenMP_CXX_FLAGS) 
-- A library with BLAS API found.
-- A library with LAPACK API found.
-- A library with BLAS API found.
-- Found AMD library: /usr/local/lib/libamd.dylib
-- Found AMD header in: /usr/local/include
-- Found CAMD library: /usr/local/lib/libcamd.dylib
-- Found CAMD header in: /usr/local/include
-- Found COLAMD library: /usr/local/lib/libcolamd.dylib
-- Found COLAMD header in: /usr/local/include
-- Found CCOLAMD library: /usr/local/lib/libccolamd.dylib
-- Found CCOLAMD header in: /usr/local/include
-- Found CHOLMOD library: /usr/local/lib/libcholmod.dylib
-- Found CHOLMOD header in: /usr/local/include
-- Found SuiteSparseQR library: /usr/local/lib/libspqr.dylib
-- Found SuiteSparseQR header in: /usr/local/include
-- Found Intel Thread Building Blocks (TBB) library: /usr/local/lib/libtbb.dylib, assuming SuiteSparseQR was compiled with TBB.
-- Found Intel Thread Building Blocks (TBB) Malloc library: /usr/local/lib/libtbbmalloc.dylib
-- Found SuiteSparse_config library: /usr/local/lib/libsuitesparseconfig.dylib
-- Found SuiteSparse_config header in: /usr/local/include
-- Found METIS library: /usr/local/lib/libmetis.dylib.
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   csfm

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Applications/XAMPP/xamppfiles/htdocs/OpenSfM-master/OpenSfM-master/cmake_build
Compiling extension...
[ 11%] Built target akaze
[ 95%] Built target vl
[100%] Built target csfm
Building package
running build
running build_py

here my pip list:

decorator (4.0.9)
ExifRead (2.1.2)
gpxpy (1.1.1)
networkx (1.11)
nose (1.3.7)
numpy (1.9.3)
pip (8.1.1)
py (1.4.31)
pytest (2.9.1)
PyYAML (3.11)
setuptools (19.4)
Shapely (1.5.13)
vboxapi (1.0)
wheel (0.26.0)
xmltodict (0.10.1)

and I'm running on OSX 10.11.4 El Capitan.

Thank you for your support and for any advice. Best, Michele

paulinus commented 8 years ago

It looks like a problem importing cv2. Can you open a python console and try import cv2? How did you install opencv?

slightHYP commented 8 years ago

Just tried to import cv2, but nothing changed.

I installed opencv as described in the documentation: brew install opencv

Thanks

paulinus commented 8 years ago

Do you mean that import cv2 on a python console works or you get an exception? Can you paste the output here?

slightHYP commented 8 years ago
Kayden-MACPRO:site-packages m.andreolli$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 12:54:16) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import cv2
>>> 

No logs, no errors :-)

paulinus commented 8 years ago

Ups. It is estrange that it works from the console and not when running the opensfm command. Can you think of any difference? Is the PYTHONPATH and python command the same on the two cases?

umbertodistaso commented 8 years ago

Unfortunately i've the same issues. I do not have issues with numpy but problems with cv2 are still present.

here my pip list

altgraph (0.10.2)
bdist-mpkg (0.5.0)
bonjour-py (0.3)
cv2 (1.0)
decorator (4.0.9)
ExifRead (2.1.2)
gpxpy (1.1.1)
macholib (1.5.1)
matplotlib (1.3.1)
modulegraph (0.10.4)
networkx (1.11)
numpy (1.8.0rc1)
pip (8.1.1)
py (1.4.31)
py2app (0.7.3)
pyobjc-core (2.5.1)
pyobjc-framework-Accounts (2.5.1)
pyobjc-framework-AddressBook (2.5.1)
pyobjc-framework-AppleScriptKit (2.5.1)
pyobjc-framework-AppleScriptObjC (2.5.1)
pyobjc-framework-Automator (2.5.1)
pyobjc-framework-CFNetwork (2.5.1)
pyobjc-framework-Cocoa (2.5.1)
pyobjc-framework-Collaboration (2.5.1)
pyobjc-framework-CoreData (2.5.1)
pyobjc-framework-CoreLocation (2.5.1)
pyobjc-framework-CoreText (2.5.1)
pyobjc-framework-DictionaryServices (2.5.1)
pyobjc-framework-EventKit (2.5.1)
pyobjc-framework-ExceptionHandling (2.5.1)
pyobjc-framework-FSEvents (2.5.1)
pyobjc-framework-InputMethodKit (2.5.1)
pyobjc-framework-InstallerPlugins (2.5.1)
pyobjc-framework-InstantMessage (2.5.1)
pyobjc-framework-LatentSemanticMapping (2.5.1)
pyobjc-framework-LaunchServices (2.5.1)
pyobjc-framework-Message (2.5.1)
pyobjc-framework-OpenDirectory (2.5.1)
pyobjc-framework-PreferencePanes (2.5.1)
pyobjc-framework-PubSub (2.5.1)
pyobjc-framework-QTKit (2.5.1)
pyobjc-framework-Quartz (2.5.1)
pyobjc-framework-ScreenSaver (2.5.1)
pyobjc-framework-ScriptingBridge (2.5.1)
pyobjc-framework-SearchKit (2.5.1)
pyobjc-framework-ServiceManagement (2.5.1)
pyobjc-framework-Social (2.5.1)
pyobjc-framework-SyncServices (2.5.1)
pyobjc-framework-SystemConfiguration (2.5.1)
pyobjc-framework-WebKit (2.5.1)
pyOpenSSL (0.13.1)
pyparsing (2.0.1)
pytest (2.9.1)
python-dateutil (1.5)
pytz (2013.7)
PyYAML (3.11)
scipy (0.13.0b1)
setuptools (21.0.0)
six (1.4.1)
xattr (0.6.4)
xmltodict (0.10.1)
zope.interface (4.1.1)

....and errors

Traceback (most recent call last):
  File "/Users/u.di.staso/Desktop/OpenSfM/bin/opensfm", line 10, in <module>
    from opensfm import commands
  File "/Users/u.di.staso/Desktop/OpenSfM/opensfm/commands/__init__.py", line 2, in <module>
    import extract_metadata
  File "/Users/u.di.staso/Desktop/OpenSfM/opensfm/commands/extract_metadata.py", line 5, in <module>
    from opensfm import dataset
  File "/Users/u.di.staso/Desktop/OpenSfM/opensfm/dataset.py", line 10, in <module>
    import cv2
ImportError: No module named cv2
paulinus commented 8 years ago

@umbertodistaso in your case, it looks like python does not find cv2. This might be that PYTHONPATH does not include the directory where cv2 is installed.

edgarriba commented 8 years ago

@slightGT @umbertodistaso Have you tried this tutorial for OpenCV Python bindings ? http://docs.opencv.org/master/tutorial_py_setup_in_fedora.html#gsc.tab=0

slightHYP commented 8 years ago

Dear all,

I've just figured out the issue 👍

I discovered from the python console that the numpy module version loaded by python was different from the one in the Python Package Index list.

STEP 1: Check the numpy version loaded. I run the following command in the python console:

>> print numpy.__version__

In my case,it returned the version 1.8.0, instead of the 1.11.0 of the pip list.

STEP 2: follow this link in order to remove all the old references of numpy: http://stackoverflow.com/questions/22815841/python-numpy-update-from-1-6-to-1-8

STEP 3: Install numpy again:

sudo pip install -U numpy

STEP 4: Check again the numpy version loaded. If numpy module not present, import it:

>> import numpy
>> print numpy.__version__

STEP 5: Run the commend reported in the running chapter of the documentation:

bin/run_all data/DATASET_NAME

Thank you for your support, let's start using OpenSfM :-) Best, Michele

AhmedSaym commented 5 years ago

to solve this problem 👍 only : uninstall numpy.exe and pip install numpy