Record the python package EXE file running error importerror, but do not prompt specific error solution

Problem Description:
I made a program, the main program is osrr.py, which imports the other two files excela.py and excelb.py. When I run in visual studio, the program can run normally, but after I use pyinstaller to package it into a separate EXE file, the operation will report an error of “importerror”, but there is no prompt to import which name, The packing command is: pyinstall – F osrr.py – P excela.py – P excelb.py — hidden import excela — hidden import excelb. The error is as shown in the figure below

Problem solving process:
when I didn’t create a new excelb.py, osrr.py and excel.py can be packaged normally. When I created a new excelb and imported it into osrr.py, an error was reported. So I created a new project in excelb.py and imported it into osrr.py. After that, an error was also reported, as shown in the figure below

I deleted all the imports in test1.py, and then tried them one by one, and found that there was a problem with this string of codes:
from pynput.keyboard import key, controller, but the code I wrote ran directly in vs without any error, so I could run normally.

Solution:
I found an article on the Internet, which introduced the reasons and solutions (I’m sorry I didn’t know how to blog before, but I can’t find that article after I finally found this function, I’m sorry for the old brother of the original author)
the cause of the problem is the version of pynput. If the latest version 1.7.3 is installed, the above problems will appear when using the package. Use “PIP install pynput” to uninstall the package, and then use the command “PIP install pynput = = 1.6.8” to install version 1.6.8. After the installation is completed, no error will be reported whether the package exe program or running directly in vs.


Read More: