This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Getting error while importing ssl " import _ssl # if we can't import it, let the error propagate ImportError: DLL load failed while importing _ssl: The specified module could not be found."
Type: behavior Stage: resolved
Components: SSL, Windows Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: Ajaya, christian.heimes, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-01-15 13:35 by Ajaya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
journal.py Ajaya, 2020-01-15 13:35 python script
Messages (4)
msg360055 - (view) Author: Ajaya (Ajaya) Date: 2020-01-15 13:35
We have built python3.7.5 and python3.8.1 source code in windows 10 machine. I have created an embedded interptreter where i am trying to "import ssl" but it is failing with error "Journal execution results for D:\workdir\PR\9616145\9616145\journal.py...
Syntax errors:
Line 98: Traceback (most recent call last):
  File "D:\workdir\PR\9616145\9616145\journal.py", line 1, in <module>
    import ssl
  File "<frozen zipimport>", line 259, in load_module
  File "D:\workdir\PR\PRUnits\PythonIssuefix381\wntx64\kits\nxbin\python\Python38.zip\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed while importing _ssl: The specified module could not be found."

This error was coming from python 3.7.4 and it was working fine till python 3.7.3. 

There is also one work around if i replaced _ssl.pyd with python3.7.3 _ssl.pyd it is working fine. I also found python 3.7.3 is using openssl-1.1.1c where as python3.7.5 and python3.8.1 is using openssl- 1.1.1d.

I have also checked in using python 3.7.5  installing  and import ssl is working fine. I have also checked that _ssl.pyd in installer  and _ssl.pyd is created by manually built size is different.

I am not getting the exact root cause what has happened. Could you please me i have already stucked  and not able to work.
msg360059 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-01-15 16:03
It sounds like Python cannot load the OpenSSL DLLs or a dependency of the OpenSSL DLLs. IIRC the libraries are called libssl.dll and libcrypto.dll. The files must be in the current DLL search path.
msg360074 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-01-15 21:11
More precisely, make sure the libcrypto-1_1.dll and libssl-1_1.dll files are in the same directory as your _ssl.pyd, but _not_ inside your Python38.zip file (zip import does not support native modules, they have to be outside of the zip).
msg360094 - (view) Author: Ajaya (Ajaya) Date: 2020-01-16 06:08
Thanks all for your quick response. That issue has been resolved by
solution given by  Steve Dower and  Christian Heimes

On Thu, Jan 16, 2020 at 2:41 AM Steve Dower <report@bugs.python.org> wrote:

>
> Steve Dower <steve.dower@python.org> added the comment:
>
> More precisely, make sure the libcrypto-1_1.dll and libssl-1_1.dll files
> are in the same directory as your _ssl.pyd, but _not_ inside your
> Python38.zip file (zip import does not support native modules, they have to
> be outside of the zip).
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue39344>
> _______________________________________
>

-- 
Regards:
Ajaya Kumar Sutar
Product Engineer
Siemens Industry Software (India) Private Limited
Tower C, Panchashil Business Park,
Cummins India Office Campus,
Survey No. 21, Balewadi,
Pune, India  411045
Tel: +91-20-39182839(O)
09764180686(P)
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83525
2021-04-17 18:27:00christian.heimessetstatus: open -> closed
resolution: fixed
stage: resolved
2020-01-16 06:08:03Ajayasetmessages: + msg360094
title: ImportError: DLL load failed while importing _ssl: The specified module could not be found." -> Getting error while importing ssl " import _ssl # if we can't import it, let the error propagate ImportError: DLL load failed while importing _ssl: The specified module could not be found."
2020-01-16 00:01:08ppperrysettitle: Getting error while importing ssl " import _ssl # if we can't import it, let the error propagate ImportError: DLL load failed while importing _ssl: The specified module could not be found." -> ImportError: DLL load failed while importing _ssl: The specified module could not be found."
2020-01-15 21:11:47steve.dowersetmessages: + msg360074
2020-01-15 16:03:08christian.heimessetmessages: + msg360059
2020-01-15 15:43:54SilentGhostsetassignee: christian.heimes

nosy: + christian.heimes
components: + SSL
versions: + Python 3.8
2020-01-15 13:35:53Ajayacreate