我已经创建了一个使用Tkinter和PyAutoGui作为依赖项的程序,并且我想创建一个可以在单独的计算机上独立运行的可执行文件。我运行代码;
pyinstaller C:\Users\ctracey\MyScripts\packagePromos.py
cmd运行良好,我成功阅读了该文件;
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窗口并关闭,并短暂显示此短消息;
Traceback (most recent call last):
File "packagePromos.py", line 3, in <module>
ModuleNotFoundError: No Module named 'pyautogui'
[25004] failed to execute script packagePromos
我只是知道这意味着PyAutoGui模块/依赖项未在可执行文件/文件夹中编译,但我想知道的原因以及如何解决它?
我已经安装了Python,PyAutoGUI,带有Pip的图像,并相应地将它们更新为最新版本,但是仍然没有运气。
答案 0 :(得分:0)
您需要指定要导入的库。
例如:
pyinstaller main.py --hiddenimport = pyautogui