title: Does libtorrent work in Python 3?
body: <p>I've tried everything over the last few days to install libtorrent in Python3. No matter what I try, I get: </p>
  
  <pre><code>Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49) 
  [GCC 7.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import libtorrent
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ModuleNotFoundError: No module named 'libtorrent'
  </code></pre>
  
  <p>I get no errors when I run:</p>
  
  <pre><code>$ sudo apt-get install python3-libtorrent
  $ sudo apt-get install libtorrent-rasterbar-dev
  </code></pre>
  
  <p>I don't really understand the difference between libtorrent, and libtorrent-rasterbar. As far as I can tell rasterbar is a dependency for libtorrent.</p>
  
  <p>The <a href="https://pypi.python.org/pypi/python-libtorrent/1.1.0" rel="nofollow noreferrer">PyPi page</a> doesn't have any binaries on it, so I can't <code>pip install</code> it. </p>
  
  <p>I can download the package from <a href="https://github.com/arvidn/libtorrent/releases" rel="nofollow noreferrer">the GitHub page</a> and install it that way by running:</p>
  
  <pre><code>$ python setup.py build
  $ python setup.py install
  </code></pre>
  
  <p>Which creates: </p>
  
  <pre><code>/home/&lt;user&gt;/anaconda3/lib/python3.6/site-packages/python_libtorrent-1.1.5-py3.6.egg-info
  </code></pre>
  
  <p>But still no change. It may have something to do with my Python3 install not being in a default location, but I'm not sure how to handle that in terms of installing libtorrent.</p>
  
  <p>I also found <a href="https://stackoverflow.com/questions/24073609/do-the-python-bindings-for-libtorrent-rasterbar-work-with-python-3">this</a> similar SO question where the accepted answer is a definitive NO. However, there are more recent comments that say that, since then, it has become possible, except no instructions are given on how to achieve it.</p>
  
  <p>I am thoroughly running out of ideas and am open to any suggestions no matter how ridiculous. Right now, I'm looking through the package I got from the GitHub page to see if I can somehow copy the code into my project directory, and then import it as a local module, but I'm not having much luck so far. If that doesn't work, I'll look at writing my own Python3 wrapper for the original C++ libtorrent library. However, I read somewhere that someone else tried and failed at this, so I'm not expecting success.</p>
  
  <p>EDIT:</p>
  
  <p>Okay, I've gotten a little further. I somehow managed to download a version of the repo that did not have a configure file, or any of the makefiles. Now that I have the right one, I run:</p>
  
  <pre><code>$ ./configure --enable-python-bindings
  $ make
  $ python setup.py build
  $ python setup.py install
  $ python 
  Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49) 
  [GCC 7.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import libtorrent
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.62.0: undefined symbol: PyClass_Type
  </code></pre>
  
  <p>I Googled this, and apparently PyClass_Type is not defined in Python3. So it seems that it's still trying to build itself for Python2, which explains the <code>libboost_python-py27.so</code> in the ImportError. The suggested solution was to compile the C++ libraries with <code>-lboost_python3</code> instead of <code>-lboost_python</code>. Line 268 of the Makefile is <code>BOOST_PYTHON_LIB = -lboost_python</code> so I changed it to <code>BOOST_PYTHON_LIB = -lboost_python3</code> and re-ran:</p>
  
  <pre><code>$ make
  $ python setup.py build
  $ python setup.py 
  </code></pre>
  
  <p>(I can't re-run <code>$ ./configure --enable-python-binding</code> because it reverts the Makefile to use lboost-python again). Unfortunately, I still get the same error message: <code>undefined symbol: PyClass_Type</code>. I know next to nothing about C++, so I'm not sure if I'm missing something really obvious about compiling the library.</p>