python - PyInstaller 生成的可执行文件中的 Python SSL 导入错误
问题描述
我正在尝试分发我创建的 Python 程序的可执行文件。为此,我正在使用PyInstaller。
我使用带有 Python 3.7 的 Windows 7 Professional 该程序在 PyCharm 中成功运行并产生预期的结果。
如 PyInstaller 手册中所述,我创建了 dist 文件夹:
pyinstaller main.py
日志输出指定该过程已成功完成。
尝试main.exe
从分发文件夹运行时,会产生以下错误:
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\rthooks\pyi_rth_certifi.py", line 11, i
n <module>
File "c:\users\tim\anaconda3\envs\timtf2_37\lib\site-packages\PyInstaller\load
er\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "ssl.py", line 98, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
[6236] Failed to execute script pyi_rth_certifi
解决方案
所以几个小时后,我设法解决了这个问题。我做了几件事,但仍然不确定实际修复的是什么,但这是我完成的分步流程:
- 使用 Anaconda 创建了一个新环境。我已将 Python 版本降级为 3.6.8,因为我看到有人提到 Python 3.7 存在一些兼容性问题
- 使用 Anaconda 安装了我的项目中的所有要求,因为有些提到混合使用
pip
和conda
. - 安装了最新版本的
pyinstaller
. - 激活新环境并
pyinstaller
在其中运行带有参数main.py
的程序脚本。--hidden-import pyodbc
就是这样,现在分布式程序可以在办公室的所有 Windows 计算机上运行。
推荐阅读
- c# - 如何在并行线程中处理 System.Drawing.Font?
- unit-testing - 在主机应用程序中模拟联合模块以开玩笑
- c# - 等待带有 ValueTask 的单个 .NET 事件
- docker - Docker 运行 - 格式问题 - docker:无效的参考格式
- html - 如何在 CSS 中使用 flex 保持 div 居中?
- python - Python - 按类别从第一行获取开始日期,从最后一行获取结束日期
- java - 如何将int转换为小端十六进制
- javascript - 这个 concat 命令如何与这个数组一起工作?
- node.js - 来自 SOAPUI 的 SOAP 请求丢失/无效的 SOAP 信封
- python - 为什么我使用 sys.stdin 和 sys.stdout 而不是使用 input() 和 print() 函数得到错误的答案?