Python 使用pyinstaller时缺少dll文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38674400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing dll files when using pyinstaller
提问by shultz
Good day!
再会!
I'm using python 3.5.2 with qt5, pyqt5 and sip14.8. I'm also using the latest pyinstaller bracnch (3.3.dev0+g501ad40).
我正在使用带有 qt5、pyqt5 和 sip14.8 的 python 3.5.2。我也在使用最新的 pyinstaller 分支(3.3.dev0+g501ad40)。
I'm trying to create an exe file for a basic hello world program.
我正在尝试为基本的 hello world 程序创建一个 exe 文件。
from PyQt5 import QtWidgets
import sys
class newPingDialog(QtWidgets.QMainWindow):
def __init__(self):
super(newPingDialog, self).__init__()
self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("hello!")
self.show()
app = QtWidgets.QApplication(sys.argv)
GUI = newPingDialog()
sys.exit(app.exec_())
At first, I used to get some errors regarding crt-msi. So I've reinstalled SDK and c++ runtime and added them to my environment. But now I keep getting errors about missing dlls (qsvg, Qt5PrintSupport)
起初,我曾经得到一些关于 crt-msi 的错误。所以我重新安装了 SDK 和 C++ 运行时并将它们添加到我的环境中。但是现在我不断收到有关缺少 dll 的错误(qsvg、Qt5PrintSupport)
6296 WARNING: lib not found: Qt5Svg.dll dependency of C:\users\me\appdata\local\programs\python\python35\lib\site-pac
kages\PyQt5\Qt\plugins\imageformats\qsvg.dll
6584 WARNING: lib not found: Qt5Svg.dll dependency of C:\users\me\appdata\local\programs\python\python35\lib\site-pac
kages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
6992 WARNING: lib not found: Qt5PrintSupport.dll dependency of C:\users\me\appdata\local\programs\python\python35\lib
\site-packages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
7535 WARNING: lib not found: Qt5PrintSupport.dll dependency of c:\users\me\appdata\local\programs\python\python35\lib
\site-packages\PyQt5\QtPrintSupport.pyd
8245 INFO: Looking for eggs
8245 INFO: Using Python library c:\users\me\appdata\local\programs\python\python35\python35.dll
8246 INFO: Found binding redirects:
I've checked and both dlls exist and have their PATH set. I also tried to manually add them to my dist folder, but it didn't helped.
我已经检查过,两个 dll 都存在并且设置了它们的 PATH。我还尝试将它们手动添加到我的 dist 文件夹中,但没有帮助。
I'll highly appreciate any advice you might have!
我将非常感谢您的任何建议!
回答by J.J. Hakala
This may be more like a workaround and Pyinstaller might need fixing.
这可能更像是一种解决方法,而 Pyinstaller 可能需要修复。
I found out that --paths
argument pointing to the directory containing Qt5Core.dll, Qt5Gui.dll, etc. helped
我发现--paths
指向包含Qt5Core.dll、Qt5Gui.dll等目录的参数有帮助
pyinstaller --paths C:\Python35\Lib\site-packages\PyQt5\Qt\bin hello.py
回答by akej74
This has now been fixed in the latest development branch of PyInstaller, see this Issue for PyInstaller on GitHub.
现在已在 PyInstaller 的最新开发分支中修复此问题,请参阅GitHub 上 PyInstaller 的此问题。
回答by Stan
I read all complicated solutions on github and stackoverflow for this problem. However, the below simple solution is what worked for me:
我在 github 和 stackoverflow 上阅读了所有针对此问题的复杂解决方案。但是,以下简单的解决方案对我有用:
Step 1: pip3 uninstall pyinstaller
第一步:pip3卸载pyinstaller
Step 2: pip install pyinstaller
第二步:pip install pyinstaller
Step 3: pyinstaller --onefile filename.py
第 3 步:pyinstaller --onefile 文件名.py
I tried this solution on 2 different computers which were facing the same problem. Both worked. Please let me know if this works for you as well. Thumbs up would be appreciated after that. Cheers
我在 2 台面临相同问题的不同计算机上尝试了此解决方案。两者都有效。请让我知道这是否也适用于您。在那之后,竖起大拇指将不胜感激。干杯
回答by Ritesh Singh
26095 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\user\appdata\local\programs\python\python36-32\DLLs\select.pyd
26095 警告:找不到 lib:c:\users\user\appdata\local\programs\python\python36-32\DLLs\select.pyd 的 api-ms-win-crt-runtime-l1-1-0.dll 依赖项
Search in C: drive for dll and set the path in pyinstaller command. The below command fixed the above pyinstaller error in windows 10:
在 C: 驱动器中搜索 dll 并在 pyinstaller 命令中设置路径。以下命令修复了 Windows 10 中的上述 pyinstaller 错误:
pyinstaller --paths "C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.17134.1_none_50c6cb8431e7428f" hello.py
回答by Yogesh
Normally adding --Path
argument pointing directory containing unfound library solves the problem. There might be a problem if command string parsing if you are using PyInstaller 3.3dev. This generally happens if the path contains spaces. In such case, you can modify pathex
argument in .spec
file generated by PyInstaller and then run it with PyInstaller to build executable.
通常添加--Path
包含未找到库的参数指向目录可以解决问题。如果您使用的是 PyInstaller 3.3dev,则命令字符串解析可能会出现问题。如果路径包含空格,通常会发生这种情况。在这种情况下,您可以修改PyInstaller 生成的文件中的pathex
参数.spec
,然后使用 PyInstaller 运行它以构建可执行文件。
pyinstaller file_name.spec
Hopefully, this will be fixed soon.....
希望这会很快得到修复......
回答by raja yadav
can use "pyinstaller --onefile filename.py". exe file will be created in dist folder
可以使用“pyinstaller --onefile filename.py”。将在 dist 文件夹中创建 exe 文件