Pyinstaller在将.py文件转换为可执行文件时未包含FoxitSDK模块。

huangapple go评论54阅读模式
英文:

Pyinstaller not including the FoxitSDK module when turning a .py to an executable

问题

我用Python制作了一个程序,可以在整个目录树中删除除第一页之外的所有PDF页面,并复制整个目录树。作为.py文件,一切都正常运行,但我希望将其转换为.exe文件,以便在没有Python或相关库的计算机上使用。当我运行pyinstaller.exe --onefile ./filename.py时,它会生成一个.exe文件,但当我运行它时,会出现以下错误:

Traceback (most recent call last):
  File "OnlyFirstPage.py", line 5, in <module>
    from FoxitPDFSDKPython3 import *
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "FoxitPDFSDKPython3\__init__.py", line 8, in <module>
ModuleNotFoundError: No module named 'fsdk'

我尝试添加--hidden-import=FoxitPDFSDKPython3到命令中,但仍然遇到了相同的问题。

英文:

I made a program in python that removes all but the first page of a pdf in a whole directory tree and makes a copy of the tree, and it all works fine as a .py file, but I wanted to turn it into an .exe so that it can be used on a computer that doesn't have python or the libraries. When I run pyinstaller.exe --onefile ./filename.py, it makes an exe but when I run it, it gives me this error:

Traceback (most recent call last):
  File &quot;OnlyFirstPage.py&quot;, line 5, in &lt;module&gt;
    from FoxitPDFSDKPython3 import *
  File &quot;PyInstaller\loader\pyimod02_importers.py&quot;, line 385, in exec_module
  File &quot;FoxitPDFSDKPython3\__init__.py&quot;, line 8, in &lt;module&gt;
ModuleNotFoundError: No module named &#39;fsdk&#39;

I tried adding --hidden-import=FoxitPDFSDKPython3 to the command, but got the same problem.

答案1

得分: 0

你是否有__init__.py文件,该文件是否与./filename.py在同一文件夹中?如果没有,请将它放在与./filename.py相同的文件夹中。

如果这不起作用,请尝试这样!

pyinstaller.exe --onefile --paths=D:\env\Lib\site-packages(在此处放置Python包的路径) .\filename.py

英文:

Do you have __init__.py file , is that file in same folder as ./filename.py, if not . Put it in same folder as ./filename.py .

if that didn't work , try this !

pyinstaller.exe --onefile --paths=D:\env\Lib\site-packages (put path to python packages here) .\filename.py

huangapple
  • 本文由 发表于 2023年6月16日 01:34:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定