0

Im trying to convert a single file python script/project into an exe using pyinstaller

Even thought pyinstaller converts the script the .exe will run and throw this

Traceback (most recent call last): File "main.py", line 4, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module File "pynput\__init__.py", line 40, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module File "pynput\keyboard\__init__.py", line 31, in <module> File "pynput\_util\__init__.py", line 76, in backend ImportError [16676] Failed to execute script main 

I'm stumped , through my trial and erroring i figured that when i replace pynput with a module like random
the convertion works fine , but i need it to work with pynput
please help , thanks in advance!

2
  • pls put the complete command you have used along with parameters. for example pyinstaller --onefile --windowed my_app.py seems like it did not import all the modules. Commented Apr 27, 2021 at 17:33
  • pyinstaller my_app.py -F i also tried to do this pyinstaller my_app.py -F --hiddenimport=pynput .and this pyinstaller my_app.py -F -p C:\pathToVenv\Lib\site-packages by the way if that helps this is a pycharm project Commented Apr 27, 2021 at 17:54

1 Answer 1

1

Authors made some changes which i feel broke the reference.
so instead of package it is referring file.

- backend = backend(__package__) + backend = backend(__name__) 

pls try to downgrade your package and check that your app still works.

pip install pynput==1.6.8 

then your command like following would work.

pyinstaller --onefile build_pkg_for.py 
Sign up to request clarification or add additional context in comments.

2 Comments

Wow that actually fixxed the problem , thank you very much!! So to understand the problem , is it a pyinstaller problem or a pynput problem , just so if it happens again with a diffrent module i can do the same thing :)
it depends on whose user base is large :) at this moment I would say the latest version of pynput and pyinstaller are incompatible.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.