【问题标题】:ImportError importing ssl in MinGW-W64 Python 3.6ImportError 在 MinGW-W64 Python 3.6 中导入 ssl
【发布时间】:2017-08-23 17:12:18
【问题描述】:

我使用 MSYS2 安装了 Python 3.6 (mingw-w64-x86_64-python3) 的 MinGW-W64 版本。导入 ssl 时,会引发 ImportError

$ python3
Python 3.6.2 (default, Aug 15 2017, 10:59:43)  [GCC 7.1.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "G:/msys64/mingw64/lib/python3.6\ssl.py", line 101, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
>>>

我不确定这是为什么。 pacman 显示已安装的 mingw-w64-x86_64-opensslopenssl/mingw64/lib/python3.6/lib-dynload/_ssl-cpython-36m.dll 存在。来自同一目录的其他 .dll 文件(如用于 jsonsqlite3 模块的文件)可以正常导入。

更奇怪的是,Python 2 版本 (mingw-w64-x86_64-python2) 没有这个问题。

【问题讨论】:

标签: python python-3.x ssl mingw pyopenssl


【解决方案1】:

这不是一个正确的解决方案(MSYS2 人员正在研究真正的解决方案),但对于其他陷入困境的人来说,这是一种临时解决方法:

安装后mingw-w64-x86_64-python3复制

  • C:\msys64\mingw64\bin\LIBEAY32.dll
  • C:\msys64\mingw64\bin\SSLEAY32.dll

  • C:\msys64\mingw64\lib\python3.6\lib-dynload\LIBEAY32.dll

  • C:\msys64\mingw64\lib\python3.6\lib-dynload\SSLEAY32.dll

之后import ssl(以及依赖它的工具,如pip3)应该可以正常工作。

【讨论】:

    猜你喜欢
    • 2015-09-30
    • 2019-04-23
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    相关资源
    最近更新 更多