0

so i am trying to import libtorrent from python file to make some code that download a torrent, but when I import it, it returns the following error

Traceback (most recent call last):
  File "/Users/myUser/Documents/someDirectory/test.py", line 1, in <module>
    import libtorrent
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/libtorrent.so, 2): no suitable image found.  Did find:
        /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/libtorrent.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03
        /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/libtorrent.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03

I'm on macOS Mojave 10.14.6. Thank you, it would help a lot.

  • Are you sure that shared library was built for MacOS, and your version of MacOS in specific? – MisterMiyagi Mar 28 '21 at 11:20
  • The libtorrent is installed builtin from the macOS, and idk how to check it, can i reinstall it for the MacOS and does the libtorrent support MacOS? Thanks – Rafi Alfarisi Mar 28 '21 at 11:27
  • 1
    The header 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03 suggests this is an [ELF, 64 bit, little endian, *Linux*](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header) file. – MisterMiyagi Mar 28 '21 at 11:29
  • I see, so can i reinstall it for the macos version? – Rafi Alfarisi Mar 28 '21 at 11:31
  • How did you install it? – Klaus D. Mar 28 '21 at 11:58
  • I don't install it, it just in there. – Rafi Alfarisi Mar 28 '21 at 15:50
  • [``libtorrent`` is not part of the standard library](https://docs.python.org/3/library/index.html), and [``site-packages`` is only used for additional libraries](https://stackoverflow.com/questions/31384639/what-is-pythons-site-packages-directory). Even if you did not explicitly install ``libtorrent``, you at least did so by extension of installing some lobrary that needs it. – MisterMiyagi Mar 28 '21 at 16:00
  • So, can i reinstall it? – Rafi Alfarisi Mar 28 '21 at 16:03

0 Answers0