I am attempting to add libtorrent to my Python. My issue is that even though I have tried many, albeit odd, workarounds (more on this later) to get libtorrent to work with my Python, I cannot for the life of me import the module.
I'll walk through what I have tried. I have stumbled upon 'solutions' that have helped me parts of the way, but not all the way through. I even tried to follow the creator's instructions himself provided on Stack Overflow.
Let's step a few steps back and observe what I have tried doing. We will start with boost. If you did not know, libtorrent requires boost in order to function. My knowledge is not grand when it comes boost, thus I will leave the explanation out of this. So, much like all instructions I followed, said that boost was required. I promptly installed boost and added its path to the environment table. I subsequently ran the bat file provided in boost and it created two files (possibly more) B2.exe and BJAM . B2 is what I was required to use for the forthcoming steps.
I continued by moving into the downloaded boost folder (ver 1.66) > tools > build > example and then editing the user-config.jam file with the additions of these items:
using msvc : 14.0 ;
using gcc : : : -std=c++11 ;
using python : 3.6 : C:\Users\XXXX\AppData\Local\Programs\Python\Python36-32 : C:\Users\XXXX\AppData\Local\Programs\Python\Python36-32\include : C:\Users\XXXX\AppData\Local\Programs\Python\Python36-32\libs ;
I then proceeded by opening an elevated x64 Native tool command prompt for VS2017 and executing the following command
b2.exe --hash openssl-version=pre1.1 link=shared libtorrent-link=shared stage_module stage_dependencies
also provided by Arvid (I believe the creator), in the libtorrent>bindings>python folder This started a 5 minute download period. It gave me the following info:
Performing configuration checks
- 32-bit : yes (cached)
- arm : no (cached)
- mips1 : no (cached)
- power : no (cached)
- sparc : no (cached)
- x86 : yes (cached)
- symlinks supported : yes (cached)
...patience...
...patience...
...patience...
...found 7252 targets...
...updating 27 targets...
ending with saying that it
...updated 27 targets...
The instructions basically stops here, so you would think that it is now properly configured. It wasn't. I immediately went to the bindings>python folder and sure enough, there exists libtorrent.pyd and libtorrent.lib files. Looked promising. I booted up a command prompt, checked Pip (pip list) and saw libtorrent in the list. Entered python and tried importing libtorrent.
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtorrent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
The pyd file exists, so I tried manually dragging it into the python DLL folder, still could not import it. I even went so far to do a manual
sys.path.append('D:\Downloads\libtorrent-rasterbar-1.1.7\libtorrent-
rasterbar-1.1.7\bindings\python')
That some people suggested doing, because it might not be linked.
I am at a loss.
I can't import it, yet it clearly exists not only in the pip list, but also in the libtorrent > bindings > python folder (pyd and lib files).
I have also tried running the setup.py file as well. Which does the same thing, but does not get me any further.
An observation I have made: the folder folder in libtorrent > bindings > python > bin folder has a weird name: "d796976f6d11336977dac24301151009" containing a src folder, libtorrent.exp, libtorrent.lib, libtorrent.pdb, libtorrent.pyd, libtorrent.pyd.manifest and libtorrent.pyd.rsp
This seems to me that the installation or download was not fully completed. It might not be this however, it's just an uneducated guess. Moreover the libtorrent.lib file found in the libtorrent > bindings > python folder & and the libtorrent.pyd file are 2 KB and 3000 KB in size respectively
Might it be corrupted? Have I not linked it correctly?
I am using Python 3.6.5 32bit (64 bit also exists, but for some reason would not work at all with libtorrent). Windows based 64 Bit system with Windows 10 installed. Boost 1.66.0. Trying to download/install/import libtorrent-rasterbar-1.1.7