litorrent python 绑定:库未加载:libboost_python38.dylib 用例:-问题 1问题 2

问题描述

用例:-

我正在尝试开发自己的 Torrent 客户端,我发现 libtorrent 是实现这一目标的有效方法之一。但是在查看其设置文档时,我遇到了很多无法相互关联的事情。所以这里有两个问题。

问题 1

我想遵循 this 文档并通过它实现它,而不是通过 python-libtorrent 安装它

根据文档,对于 libtorrent pre requisites 的先决条件,必须在其系统上设置 boost 设置和 b2。以下是我执行的命令:-

  1. 已下载:- boost_1_76_0.tar.bz2 从 https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/

  2. 解压文件并进入并运行./bootstrap.sh --prefix=/usr/lib/bootstrap

  3. ./b2 install --prefix=/usr/lib/b2

  4. 在 PATH 环境变量中添加/usr/lib/b2/bin ->

    export PATH="$JAVA_HOME/bin:/usr/lib/b2/bin:$PATH"

  5. 设置 BOOST_BUILD_PATH && BOOST_ROOT ->

    export BOOST_ROOT=/Users/pratapalokraj/boost_1_76_0
    export BOOST_BUILD_PATH=$BOOST_ROOT/tools/build
    
  6. 我不明白为什么在这个文档 (https://www.libtorrent.org/building.html) 中它要求运行 cmake 命令(我认为它与我的东西无关,所以我跳过了它)。

  7. 进入 libtorrent 文件夹并运行以下命令:-

    python setup.py build
    python setup.py install
    

8 现在,当我尝试导入 libtorrent 时,它抛出了一个错误:-

(base) Apples-MacBook-Pro:libtorrent cobyUser$ python
Python 3.8.3 (default,Jul  2 2020,11:26:31)
[Clang 10.0.0 ] :: Anaconda,Inc. on darwin
Type "help","copyright","credits" or "license" for more information.
>>> import libtorrent as lt
Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
ImportError: dlopen(/Applications/anaconda3/lib/python3.8/site-packages/python_libtorrent-2.0.4-py3.8-macosx-10.9-x86_64.egg/libtorrent.cpython-38-darwin.so,2): Library not loaded: libboost_python38.dylib
  Referenced from: /Applications/anaconda3/lib/python3.8/site-packages/python_libtorrent-2.0.4-py3.8-macosx-10.9-x86_64.egg/libtorrent.cpython-38-darwin.so
  Reason: image not found

上述问题与我面临的设置问题有关。

问题 2

我尝试从 here 浏览 boost 库文档,但我无法理解 boost 库和 b2 的概念,以及为什么必须内置才能使 litorrent 工作。我知道 libtorrent 是用 C++ 编写的,我们正在尝试为它找到 python 绑定,但是如果有人可以指出我的任何文档、链接或简要概述它是什么,它会真的很有帮助

[编辑] - 问题 1 的解决方

经过大量搜索后,我在这里找到了一些文档:- quickbook-install 和 我不知道到底发生了什么,但我确实执行了以下步骤,现在 python 能够识别 libtorrent 库。

  1. vi ~/user-config.jam

    粘贴以下内容

    using xsltproc
         : /opt/local/bin/xsltproc
         ;
    
     using boostbook
         : /opt/local/share/xsl/docbook-xsl/
         : /opt/local/share/xml/docbook/4.2
         ;
    
  2. sudo port install libxslt docbook-xsl-nons docbook-xml-4.2

  3. 进入 libtorrent 文件夹,然后运行 ​​b2 variant=release link=static runtime-link=static debug-symbols=on

  4. b2 install --prefix=/usr/local

我认为可能缺少一些依赖项。但我仍然怀疑这个 python 绑定是什么以及如何工作。我不明白 boost 库和 b2 的确切概念。

如果有人能指出正确的方向并提供简要概述,我将不胜感激,尤其是 b2 variant=release link=static runtime-link=static debug-symbols=on 正在做什么。我们所说的库的静态链接究竟是什么意思。

注意:- 对于像我这样正在努力从源代码构建 libtorrent 的人,b2bjam 的更新名称。您可以找到参考 here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)