pyinstaller icon indicating copy to clipboard operation
pyinstaller copied to clipboard

Document that `qt.tlsbackend.ossl: Failed to load libssl/libcrypto.` can be caused by missing `libssl-1_1-x64.dll` file

Open bersbersbers opened this issue 2 years ago • 2 comments

For months, I have been wondering why I was getting

qt.tlsbackend.ossl: Failed to load libssl/libcrypto.

warnings while building my PySide6-based app, even with --log-level=ERROR.

My app does not use network communication and appeared to be working fine, but it's hard to be certain with such kind of error messages.

I now found out that by adding a folder containing libssl-1_1-x64.dll to PATH, e.g.,

set PATH=%PATH%;%ProgramFiles%\Git\mingw64\bin

I can make this message go away. I think this would be great to document. (Maybe this issue is enough already for other people to find via Google.)

I am a bit surprised pyinstaller does not error itself when not finding it here: https://github.com/pyinstaller/pyinstaller/blob/d6ff0802dd6f2fbeccb4a6c47e1cf24c61c31205/PyInstaller/utils/hooks/qt/init.py#L604-L608

[By the way, if there was a similarly simple fix for qt.core.qobject.connect: QObject::connect(QObject, Unknown): invalid nullptr parameter, that would be appreciated as well. It's the only message standing between me and a completely clean console output when building with pyinstaller.

Edit: this one comes from here https://github.com/pyinstaller/pyinstaller/blob/d6ff0802dd6f2fbeccb4a6c47e1cf24c61c31205/PyInstaller/utils/hooks/qt/init.py#L591-L595 and is independent of PyInstaller, as it can be reproduced using python -c "from PySide6.QtNetwork import QSslSocket; QSslSocket.supportsSsl()". I reported https://bugreports.qt.io/browse/PYSIDE-2216 for that.]

bersbersbers avatar Feb 04 '23 15:02 bersbersbers

For months, I have been wondering why I was getting

qt.tlsbackend.ossl: Failed to load libssl/libcrypto.

warnings while building my PySide6-based app, even with --log-level=ERROR.

Because the error message is coming from the Qt libraries, not PyInstaller, so PyInstaller's log level has no effect on it.

My app does not use network communication and appeared to be working fine, but it's hard to be certain with such kind of error messages.

I now found out that by adding a folder containing libssl-1_1-x64.dll to PATH, e.g.,

set PATH=%PATH%;%ProgramFiles%\Git\mingw64\bin

I can make this message go away. I think this would be great to document. (Maybe this issue is enough already for other people to find via Google.)

PySide2 and PySide6 PyPI wheels do not ship the OpenSSL library, so you need to provide your own copy. That's likely due to import/export restrictions as documented here and here. (PyQt5 and PyQt6 wheels do provide their own copy of OpenSSL libraries).

I am a bit surprised pyinstaller does not error itself when not finding it here:

https://github.com/pyinstaller/pyinstaller/blob/d6ff0802dd6f2fbeccb4a6c47e1cf24c61c31205/PyInstaller/utils/hooks/qt/init.py#L604-L608

Because OpenSSL libraries are not necessarily provided by wheels, we consider them as optional and do not error out when they cannot be found.

But we might need to consider searching all PATH locations in addition to the standard Qt library paths.

rokm avatar Feb 04 '23 21:02 rokm

Thanks for the explanations, makes a lot of sense. So I agree this doesn't have to go into pyinstaller documentation, and presumably this issue is enough for other people to make sense of it.

Because the error message is coming from the Qt libraries, not PyInstaller, so PyInstaller's log level has no effect on it.

Yes, I noticed later it can be reproduced using the same python -c "from PySide6.QtNetwork import QSslSocket; QSslSocket.supportsSsl()" call if libssl-1_1-x64.dll is not on the PATH.

But we might need to consider searching all PATH locations in addition to the standard Qt library paths.

Aren't you already doing that? At least in my case, the warning disappears after set PATH=%PATH%;%ProgramFiles%\Git\mingw64\bin.

(Edit: Fell to the same trap again - since that warning is emitted by Qt, it's disappearance means nothing with respect to pyinstaller.)

bersbersbers avatar Feb 04 '23 23:02 bersbersbers