简体   繁体   English

执行 .exe 时没有名为“img2pdf”的模块 - pyinstaller

[英]error No module named 'img2pdf' when executing .exe - pyinstaller

I'm am trying to build an .exe file with pyinstaller.我正在尝试使用 pyinstaller 构建一个 .exe 文件。 When launching the build .exe file I have the following error :启动构建 .exe 文件时,出现以下错误:

ModuleNotFoundError: No module named 'img2pdf' ModuleNotFoundError: 没有名为“img2pdf”的模块

I have already build some .exe with pyinstaller, which are working.我已经用 pyinstaller 构建了一些 .exe,它们正在运行。 So I guess the problem is not pyinstaller.所以我想问题不在于pyinstaller。 I am also using Pycharm with a virtual environnement.我也在虚拟环境中使用 Pycharm。

The code is working well when running on Pycharm.该代码在 Pycharm 上运行时运行良好。

With the --debug all option of pyinstaller, I can see the following lines :使用 pyinstaller 的 --debug all 选项,我可以看到以下几行:

img2pdf not found in PYZ Traceback (most recent call last): File "download_pdf.py", line 7, in File " 在 PYZ Traceback 中找不到 img2pdf(最近一次调用最后一次):文件“download_pdf.py”,第 7 行,在“文件”中

importlib._bootstrap>", line 983, in _find_and_load File "", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'img2pdf' [4812] Failed to execute script download_pdf importlib._bootstrap>", line 983, in _find_and_load File "", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'img2pdf' [4812] 无法执行脚本 download_pdf

I tried pip install img2pdf in the Terminal of pycharm (virtual environnement) and in the command prompt of my OS (windows 10).我在 pycharm 的终端(虚拟环境)和我的操作系统(Windows 10)的命令提示符中尝试了 pip install img2pdf。

Does anyone know what's wrong ?有谁知道出了什么问题?

I had to use the following option of pyinstaller : --hidden-import=img2pdf我不得不使用 pyinstaller 的以下选项:--hidden-import=img2pdf

It now works.它现在可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM