Wednesday, May 15, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 541  / 2 Years ago, thu, may 5, 2022, 11:42:30

When trying to snap a project, we got back this error from snapcraft:



Traceback (most recent call last):
File "/usr/bin/snapcraft", line 31, in <module>
snapcraft.main.main()
File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 226, in main
return run(args, project_options)
File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 282, in run
lifecycle.snap(project_options, args['<directory>'], args['--output'])
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 289, in snap
snap = execute('prime', project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 103, in execute
_Executor(config, project_options).run(step, part_names)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 161, in run
self._run_step(step, part, part_names)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 197, in _run_step
getattr(part, step)()
File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler.py", line 383, in prime
dependencies = _find_dependencies(self.snapdir, snap_files)
File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler.py", line 723, in _find_dependencies
ms = magic.open(magic.NONE)
AttributeError: module 'magic' has no attribute 'open'


What does it mean, and how can it be solved?


More From » snap

 Answers
0

There are two python modules named magic, with different APIs.



The one that snapcraft requires is packaged as a deb named python3-magic. This one corresponds to the module file-magic in pypi: https://pypi.python.org/pypi/file-magic



The other one is just called magic in pypi: https://pypi.python.org/pypi/magic



So if you do:



sudo pip install magic


You will get the wrong one, and it will be installed to a path that takes precedence over the python3-magic deb installed with apt. That's what causes the error.



To check if you have the other magic module installed from pip:



pip3 list | grep magic


And to remove it and fix snapcraft:



pip3 uninstall magic

[#12835] Saturday, May 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tusmuumu

Total Points: 195
Total Questions: 122
Total Answers: 104

Location: Oman
Member since Tue, Feb 7, 2023
1 Year ago
;