OpenDroneMap / ODM

A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, balloon or kite images. 📷
https://opendronemap.org
GNU Affero General Public License v3.0
4.92k stars 1.11k forks source link

SNAP: ModuleNotFoundError: No module named 'cv2' #1438

Closed sysdef closed 2 years ago

sysdef commented 2 years ago

This error was ignored in http://community.opendronemap.org/c/opendronemap so I open an issue here

$ sudo /snap/bin/opendronemap 
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f66cf4d6740 (most recent call first):
<no Python frame>
$ uname -a; cat /etc/debian_version 
Linux can 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 GNU/Linux
11.2
pierotofy commented 2 years ago

Thanks for reporting the issue!

Currently our snap image hasn't been updated in a while due a build issue with https://github.com/diddlesnaps/snapcraft-container/issues/8 (not sure if this is related, but it could be).

Camilochiang commented 2 years ago

Til today, August 9, this problem persist.

lucyllewy commented 2 years ago

Hi, @pierotofy , I have good news, I believe I've fixed the container image so you can re-enable the snap build.

pierotofy commented 2 years ago

Thanks @diddledani ! 🙏 I've seen the changes in the container image, but haven't tested it. I will sometimes this weekend (unless somebody beats me to it).

pierotofy commented 2 years ago

It built! 🎉

JeroenDelcour commented 2 years ago

I'm still getting the same No module named 'encodings' error on a fresh install through snap. I see the snap image has been updated yesterday so I assumed the fixed version had been deployed. Am I missing something?

JeroenDelcour commented 2 years ago

Thanks for the fix, but it seems the snap publishing pipeline is broken so I'm unable to test it.

pierotofy commented 2 years ago

Mm, something else seems to be breaking the build, as you pointed out. I'm not sure of the cause.

pierotofy commented 2 years ago

I made some changes, which seemed to have worked (?) https://github.com/OpenDroneMap/ODM/runs/8210390371?check_suite_focus=true

I haven't tested as I don't have snap installed locally.

lucyllewy commented 2 years ago

oh yes, that was my bad. I forgot to remove the part that tries to use snap/local after removing all the files from the directory. Well done, you made the correct fix that I would have if I had got here earlier :-)

JeroenDelcour commented 2 years ago

Thanks for the fix! The No module named 'encodings' error seems fixed. However, I'm now getting another missing dependency:

Traceback (most recent call last):
  File "/snap/opendronemap/177/odm/run.py", line 15, in <module>
    from opendm.utils import get_processing_results_paths, rm_r
  File "/snap/opendronemap/177/odm/opendm/utils.py", line 3, in <module>
    from opendm.photo import find_largest_photo_dims
  File "/snap/opendronemap/177/odm/opendm/photo.py", line 17, in <module>
    from opendm import get_image_size
  File "/snap/opendronemap/177/odm/opendm/get_image_size.py", line 2, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

Should I make a new issue for this?

ArthurTlprt commented 2 years ago

Same issue than @JeroenDelcour after installing ODM via snap on Ubuntu 21.

pierotofy commented 2 years ago

No need for a new issue. Mm, something is still broken. Probably a PYTHONPATH issue or the cv2 module not being included in the snap package.

pierotofy commented 2 years ago

One more attempt: https://github.com/OpenDroneMap/ODM/commit/081d4c89487137512b8f3b0e84c4acf39625af84

pierotofy commented 2 years ago

I will assume this has been solved, if not please feel free to re-open? 🙏

JeroenDelcour commented 2 years ago

It has not been solved. Updating the snap package and running opendronemap without any arguments still shows the same error. Have you tested your own commit? Are you not getting this error?

You can leave it closed if you like, I'm personally not going to put more time into this. I rely on opendronemap in a production setting, so until the snap release gets better testing to show its reliable, I'm going to stick to the Docker image.

pierotofy commented 2 years ago

Fixed and tested with https://github.com/OpenDroneMap/ODM/commit/61d1865bd3a522106461b8a9d754039eaa122ecc and https://github.com/OpenDroneMap/ODM/commit/093929dd914ee56fbfe6016769eb0bdaa1e62fbf

sysdef commented 2 years ago

Thank you for fixing that!

JeroenDelcour commented 2 years ago

Thanks for fixing!

It took me a minute to figure out how to use it, so for anyone else wondering: it expects an absolute file path, rather than relative to the present working directory.