1

I'm trying to get osm-bundler to work, but I run into this problem:

Traceback (most recent call last):
  File "RunBundler.py", line 9, in <module>
    manager.preparePhotos()
  File "/Users/PeterE/Downloads/osm-bundler/osmbundler/__init__.py", line 121, in preparePhotos
    self._preparePhoto(photoInfo)
  File "/Users/PeterE/Downloads/osm-bundler/osmbundler/__init__.py", line 176, in _preparePhoto
    self.extractFeatures(photo)
  File "/Users/PeterE/Downloads/osm-bundler/osmbundler/__init__.py", line 244, in extractFeatures
    self.featureExtractor.extract(photo, self.photoDict[photo])
  File "/Users/PeterE/Downloads/osm-bundler/osmbundler/features/siftvlfeat.py", line 16, in extract
    subprocess.call([self.executable, "%s.jpg.pgm" % photo, "-o", "%s.key" % photo])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

This is caused when I run this command:

python RunBundler.py --photos="/Users/PeterE/Desktop/osmbundlertest"

I can put in any relevant lines from the Python scripts, but I have no idea which one it is now. The output before the error is:

Working directory created: /var/folders/rq/5mypbx554jgflr6c8097zltc0000gn/T/osm-bundler-CXSOEi
BundlerMatching executable path: /Users/PeterE/Downloads/osm-bundler/software/bundler/bin/KeyMatchFull
Sift executable path: /Users/PeterE/Downloads/osm-bundler/software/vlfeat/bin/glx/sift

Processing photo 'IMG_0055.JPG':
    Entry for the camera 'Apple', 'iPod touch' does not exist in the camera database
    Can't estimate focal length in pixels for the photo '/Users/PeterE/Desktop/osmbundlertest/IMG_0055.JPG'
    Copy of the photo has been scaled down to 1200x896
    Extracting features with the SIFT method from VLFeat library...
APCoding
  • 303
  • 2
  • 19
  • What do you get by running `python --version` and what system is this on? – tijko Mar 29 '17 at 21:59
  • @tijko It returned Python 2.7.12 and I'm running a Mac Mini with macOS Sierra. – APCoding Mar 29 '17 at 22:38
  • Have you checked other [posts](http://stackoverflow.com/questions/27606653/oserror-errno-8-exec-format-error) recommending adding the shebang? – tijko Mar 29 '17 at 23:05
  • @tijko I tried changing the line in `siftvlfeat` to `subprocess.call([self.executable, "#!/bin/sh\n%s.jpg.pgm" % photo, "-o", "%s.key" % photo])`. This didn't work, but it is the right way to do it? – APCoding Mar 29 '17 at 23:23
  • @tijko Isn't `self.executable` some sort of object? I can't find a file that's named that. Looking around some more, it's determined by either this (`self.executable = os.path.join(distrDir, "bundler/bin/KeyMatchFull.exe")`) or this (`self.executable = os.path.join(distrDir, "bundler/bin/KeyMatchFull")`), depending on the system. However, I can't find the file `KeyMatchFull`, only an `.exe` version (for Windows, presumably). Any ideas? – APCoding Mar 30 '17 at 01:49
  • Add the shebag line to the file `/Users/PeterE/Downloads/osm-bundler/osmbundler/features/siftvlfeat.py` itself (meaning the shebang is the first line in said file) and let me know what happens... – tijko Mar 30 '17 at 09:19
  • @tijko I added `#!/bin/sh` to the top of the Python file (is this what you had in mind?)... it didn't make a difference. I don't know if you already knew this, but `self.executable` is a path to the file `/Users/PeterE/Downloads/osm-bundler/software/vlfeat/bin/glx/sift`. `sift` is an executable. – APCoding Mar 31 '17 at 00:22
  • You need to add a shebang for the python environment `#!/usr/bin/env python` inside of `siftvlfeat.py`. I'm not familiar with this project but cursory googling shows this is usually the case with the traceback error you showed when using `subprocess` – tijko Mar 31 '17 at 00:29
  • Keep me posted... – tijko Mar 31 '17 at 00:38
  • @tijko I also tried that after looking around a bit, but it didn't help. But I think I solved my problem! I added `shell=True` and it seemed to work. Thanks for your help! (I have another error, but I think it's unrelated (it's a file not found error, and the file it's looking for has the name of my image files, but a different extension`.key` extension)) – APCoding Mar 31 '17 at 02:30
  • `shell=True` is almost always a bad choice as it poses a security risk. If you post your full subprocess statement I could have a look as to how best to solve it. – Montmons Mar 31 '17 at 18:07

0 Answers0