使用 PyInstaller 制作的可执行文件中缺少 PyAutoGui 模块 [英] PyAutoGui module missing from Executable file made with PyInstaller

查看:58
本文介绍了使用 PyInstaller 制作的可执行文件中缺少 PyAutoGui 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用 Tkinter 和 PyAutoGui 作为依赖项的程序,我想创建一个可以在单独的机器上独立运行的可执行文件.我运行运行代码;

I've created a program that uses Tkinter and PyAutoGui as dependencies and I want to create a executable file that can run independently on a separate machine. I run run the code;

pyinstaller C:\Users\ctracey\MyScripts\packagePromos.py

cmd 运行良好,我成功编译;

The cmd run fine and I get a successful compile reading this;

88 INFO: PyInstaller: 3.4
88 INFO: Python: 3.7.1
88 INFO: Platform: Windows-10-10.0.16299-SP0
91 INFO: wrote C:\Users\ctracey\packagePromos.spec
95 INFO: UPX is not available.
96 INFO: Extending PYTHONPATH with paths
['C:\\Users\\ctracey\\MyScripts', 'C:\\Users\\ctracey']
97 INFO: checking Analysis
225 INFO: checking PYZ
241 INFO: checking PKG
252 INFO: Building because toc changed
252 INFO: Building PKG (CArchive) PKG-00.pkg
290 INFO: Building PKG (CArchive) PKG-00.pkg    completed successfully.
292 INFO: Bootloader    c:\users\ctracey\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
292 INFO: checking EXE
304 INFO: Building because name changed
304 INFO: Building EXE from EXE-00.toc
305 INFO: Appending archive to EXE C:\Users\ctracey\build\packagePromos\packagePromos.exe
317 INFO: Building EXE from EXE-00.toc completed successfully.
324 INFO: checking COLLECT
336 INFO: Building COLLECT COLLECT-00.toc
3439 INFO: Building COLLECT COLLECT-00.toc completed successfully.

但是当我去运行该程序时,一个 CMD 窗口会弹出并关闭,显示此短消息;

but when I go to run the program a CMD windows pops up and closes briefly showing this short message;

Traceback (most recent call last): 
  File "packagePromos.py", line 3, in <module>
ModuleNotFoundError: No Module named 'pyautogui'
[25004] failed to execute script packagePromos

我只知道这意味着 PyAutoGui 模块/依赖项没有在 Executable 文件/文件夹中编译,但我想知道为什么以及如何修复它?

I know simply this means that the PyAutoGui module/dependecy was not compiled in the Executable file/folder but what I want to know is why and how do I fix it so it will be?

我已经安装了 Python、PyAutoGUI、Image with Pip 并相应地将它们更新到最新版本,但仍然没有运气.

I've installed Python, PyAutoGUI, Image with Pip and updated them accordingly to the latest version and still no luck.

推荐答案

需要指定要导入的库.

例如:

pyinstaller main.py --hiddenimport = pyautogui

这篇关于使用 PyInstaller 制作的可执行文件中缺少 PyAutoGui 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆