How does one run mapillary_tools on Linux?

How does one run mapillary_tools on Linux?
What I’ve done is:

$ git clone https://github.com/mapillary/mapillary_tools.git
$ python3 mapillary_tools --help
Traceback (most recent call last):
File “/usr/lib/python3.9/runpy.py”, line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.9/runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “/home/fgouget/projects/mapillary_tools/mapillary_tools/main.py”, line 3, in
from . import commands, VERSION
ImportError: attempted relative import with no known parent package
$ python3 --version
Python 3.9.2

I am certainly missing something very basic. I have made various attempts with PYTHONPATH to no avail.

Use pip instead of git.

python3 -m pip install --upgrade git+https://github.com/mapillary/mapillary_tools
1 Like

That does not help : from my previous message the error happens on line 3 of mapillary_tools/main.py, way before it tries to load the dependencies installed by pip.

From what I figured out the “from .” syntax does not work anymore with Python >= 3.6. This is confirmed by tests on Debian 9 (Python 3.5.3) which gets past line 3, and Debian 11 which gives me the error I reported.

The fix is to change that from line as follows:

diff --git a/mapillary_tools/main.py b/mapillary_tools/main.py
index 9a07e0f…8ca7be2 100644
— a/mapillary_tools/main.py
+++ b/mapillary_tools/main.py
@@ -1,6 +1,6 @@
import sys
import argparse
-from . import commands, VERSION
+from mapillary_tools import commands, VERSION

def main():

Side note: pip cannot be used ‘instead of’ git: the proposed command does not check out the mapillary_tools source so it’s still necessary to then use git to check out the source.

It seems that mapillary_tools is not installed

$ git clone https://github.com/mapillary/mapillary_tools.git
$ python3 setup.py install # install it
$ python3 -m mapillary_tools --help