Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'imp' when building #47

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

q84fh
Copy link
Contributor

@q84fh q84fh commented Oct 30, 2024

When building with python 3.12.3 I've got: ModuleNotFoundError: No module named 'imp'.

It turned out that the imp module is deprecated in favour of importlib and slated for removal in Python 3.12

It has been fixed in recent PyInstaller, so I've just dumped it version to lates in setup.cfg and I hope that it won't break anything on older Pythons.

Full traceback (I've added set -o xtrace to print commands):

+ pyinstaller --onefile ./evdevremapkeys/evdevremapkeys.py
Traceback (most recent call last):
  File "/home/q84fh/bin/evdevremapkeys/venv/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/PyInstaller/__main__.py", line 81, in run
    import PyInstaller.building.build_main
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 35, in <module>
    from ..depend import bindepend
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/PyInstaller/depend/bindepend.py", line 30, in <module>
    from . import dylib, utils
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/PyInstaller/depend/utils.py", line 28, in <module>
    from ..lib.modulegraph import util, modulegraph
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/PyInstaller/lib/modulegraph/util.py", line 8, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
+ mkdir bundle
+ staticx ./dist/evdevremapkeys ./bundle/evdevremapkeys
Traceback (most recent call last):
  File "/home/q84fh/bin/evdevremapkeys/venv/bin/staticx", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/__main__.py", line 49, in main
    generate(args.prog, args.output,
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/api.py", line 328, in generate
    gen.generate(output=output)
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/api.py", line 115, in generate
    self._get_bootloader()
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/api.py", line 85, in _get_bootloader
    prog_mach = get_machine(self.orig_prog)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/elf.py", line 324, in get_machine
    with open_elf(path) as elf:
         ^^^^^^^^^^^^^^
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/elf.py", line 318, in open_elf
    return ELFFileX.open(path, mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/q84fh/bin/evdevremapkeys/venv/lib/python3.12/site-packages/staticx/elf.py", line 263, in open
    return cls(open(path, mode), path=path)
               ^^^^^^^^^^^^^^^^

@philipl philipl merged commit a3c2331 into philipl:master Oct 31, 2024
1 check failed
@philipl
Copy link
Owner

philipl commented Oct 31, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants