-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Background
There are multiple open issues in the repository regarding DLL import errors on Windows when using the Python bindings. These errors primarily arise due to missing OpenSSL DLLs (libcrypto-1_1-x64.dll
and libssl-1_1-x64.dll
) or incorrect side-by-side configuration.
Current Issues
Below are the related issues:
- ImportError: DLL load failed while importing libtorrent: #7920
- ImportError: DLL load failed while importing libtorrent #7338
- Python 3.10 - ImportError: DLL load failed while importing libtorrent: The specified module could not be found. #6689
Proposal
This discussion aims to resolve these errors systematically by evaluating possible approaches:
1. Bundling OpenSSL DLLs in the libtorrent Wheel
- Include
libcrypto-1_1-x64.dll
andlibssl-1_1-x64.dll
in the Windows wheel package. - Users can install the wheel without needing to manage DLLs manually.
- Pros: Simple for users.
- Cons: Larger wheel size, requires regular updates for security.
2. Requiring a Separate Wheel for OpenSSL
- Create a new wheel package (
libtorrent-openssl
orlibtorrent-windows-dll
) that installs the required DLLs alongsidelibtorrent
. - Notably, in Issue #7338, a user mentioned creating a custom wheel package (
libtorrent-windows-dll
) to address this problem. This package contained the missing DLLs and placed them next to the.pyd
file insite-packages/libtorrent
. A similar approach could be formalized to ensure seamless installation. - Automatically install this dependency when installing
libtorrent
. - Pros: Keeps
libtorrent
lightweight, DLLs are managed separately. - Cons: Adds complexity and requires coordination between the two packages.
3. Static Linking of OpenSSL Libraries
- Build the libtorrent wheel with statically linked OpenSSL libraries.
- Pros: No runtime DLL dependency.
- Cons: Larger binary size, harder to update OpenSSL for security.
4. Dynamic Download of DLLs
- Modify the
libtorrent
wheel to download the required DLLs at runtime if missing. - Pros: Keeps the wheel lightweight, always fetches the latest DLLs.
- Cons: Requires internet access and adds runtime complexity.
5. Improved Documentation
- Update installation instructions to clearly explain how to install and configure OpenSSL manually on Windows.
- Pros: Simple for maintainers.
- Cons: Leaves the burden on users.
Workarounds
Until a permanent solution is implemented, users can resolve the DLL import errors with the following workarounds:
Option 1: Place DLLs in System32
(default PATH location)
- Download the required DLLs (
libcrypto-1_1-x64.dll
andlibssl-1_1-x64.dll
) from a trusted source, such as the official OpenSSL binaries. - Copy these DLLs to
C:\\Windows\\System32
, which is included in the PATH by default.
Option 2: Place DLLs next to the .pyd
- Locate the
libtorrent.cpXXX-win_amd64.pyd
file in yoursite-packages/libtorrent
directory (e.g.,C:\\Python310\\Lib\\site-packages\\libtorrent
). - Download the required DLLs and place them in the same directory as the
.pyd
file.
These workarounds should resolve the import errors until a more seamless solution is provided.
Call to Action
We invite feedback from the community and the maintainers, especially @arvidn @AllSeeingEyeTolledEweSew and @baseplate-admin, on which approach to pursue. Let us collaboratively decide the best way to resolve these recurring DLL import errors.