【发布时间】:2021-01-11 10:03:22
【问题描述】:
我正在使用 pyinstaller 创建一个独立的 exe 文件,但是当我尝试运行它时出现“modulenotfound”错误。即使 PIL 模块与我的所有其他模块位于相同的“站点包”文件夹中,它也无法找到它。如何告诉它 PIL 模块在哪里?
我在使用 pyinstaller 时在我的 cmd 行中尝试了以下标志,但它们都不起作用:
--hidden-import=Pillow
--hidden-import='PIL'
--hidden-import='Pillow'
关于 PIL 模块,我的脚本使用以下代码行:
from PIL import Image, ImageTk
脚本中一切正常,只有当我使用 pyinstaller 时才会出现问题。
【问题讨论】:
-
试试
--hidden-import PIL。顺便说一句,您是否将 PyInstaller 升级到最新版本(4.0)?PIL(枕头)自动包含在我的 PyInstaller 4.0 和 Windows 7 下的 Python 3.8.5 中。 -
我正在运行 pyinstaller 4.0、python 3.8.3 和 windows 10。我尝试了
--hidden-import PIL,但它不起作用,仍然给我 modulenotfound 错误
标签: tkinter python-imaging-library pyinstaller modulenotfounderror