niess / python-appimage

AppImage distributions of Python
https://python-appimage.readthedocs.io/en/latest/
GNU General Public License v3.0
170 stars 24 forks source link

Attribute error on run #50

Closed miAndreev closed 2 years ago

miAndreev commented 2 years ago

Hi, when I run the module the I have an error: AttributeError: module 'importlib' has no attribute 'util'

When I change the import in python_appimage/utils/compat.py from import importlib to import importlib.utils all works.

My colleagues and I tested it on different machines - on Ubuntu 20.04 and 22.04 with python 3.8, 3.9 and 3.10 and the results are consistent.

The command and output:


user@server# ./tt/bin/python-appimage -v build app -p 3.9 -l manylinux_2_28_aarch64 appimage_meta
Traceback (most recent call last):
  File "/home/user/./tt/bin/python-appimage", line 8, in <module>
    sys.exit(main())
  File "/home/user/tt/lib/python3.9/site-packages/python_appimage/__main__.py", line 100, in main
    command = import_module(module, package=__package__)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/user/tt/lib/python3.9/site-packages/python_appimage/commands/build/app.py", line 10, in <module>
    from ...appimage import build_appimage
  File "/home/user/tt/lib/python3.9/site-packages/python_appimage/appimage/__init__.py", line 1, in <module>
    from .build import build_appimage
  File "/home/user/tt/lib/python3.9/site-packages/python_appimage/appimage/build.py", line 7, in <module>
    from ..utils.compat import decode
  File "/home/user/tt/lib/python3.9/site-packages/python_appimage/utils/compat.py", line 27, in <module>
    find_spec = importlib.util.find_spec
AttributeError: module 'importlib' has no attribute 'util'```

To prevent braking the current behavior maybe it is possible to put the import in try block and when import of importlib.lib fails, the import of the importlib will be done?
nightwatch92 commented 2 years ago

Hi, experienced the same issue. There is PR for it: https://github.com/niess/python-appimage/pull/51

niess commented 2 years ago

Sorry about this compat issue. Thank your for the PR. It has been merged.