本文介绍了将pynput与pyinstaller一起使用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个朋友让我给他写一个程序,我用 pynput 来处理一些输入和其他功能.当我使用 pyinstaller 将程序转换为可执行文件时,启动可执行文件会出现以下错误: File site-packages\pynput\keyboard\__init__.py", line 31, in 文件site-packages\pynput\_util\__init__.py",第82行,后端导入错误[11492] 无法执行脚本friend_project

A friend of mine asked me to write him a program, and I used pynput to handle some of the inputs and other features. When I convert the program an executable with pyinstaller, launcing the executable gives me this error: File "site-packages\pynput\keyboard\__init__.py", line 31, in <module> File "site-packages\pynput\_util\__init__.py", line 82, in backend ImportError [11492] Failed to execute script friend_project

我尝试过使用 pyinstaller 命令 pyinstaller --onefilefriend_project.py,并使用 auto-py-to-exe 来运行它.

I have tried using the pyinstaller command pyinstaller --onefile friend_project.py, and also using auto-py-to-exe to run it.

将 pyinstaller 与其他模块(如 pygame 或 pyopengl)一起使用不会给我带来任何错误,但这个模块确实如此.使用 python inturpeter 自行运行脚本可以正常工作,但我希望它是一个 exe,这样我就可以将它提供给他,而他不需要 python 来运行它.

Using pyinstaller with other modules like pygame or pyopengl gives me no error, but this one module does.Running the script by it self with the python inturpeter works fine, but I would perfer to have it be an exe so I can give it to him with out him needing python to run it.

推荐答案

请回退到 1.6.8 版本的 pynput.pip安装pynput==1.6.8

Please fall back to 1.6.8 version of pynput.pip install pynput==1.6.8

这篇关于将pynput与pyinstaller一起使用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 06:32