Skip to main content
 首页 » 编程设计

python之ubuntu 16.04 中缺少 boost_python3

2024年10月17日7mate10pro

我正在尝试在 Ubuntu 16.04 中安装 boost.numpy。我尝试了这些命令来安装 boost.numpy

**git clone https://github.com/ndarray/Boost.NumPy.git 
 cd Boost.NumPy && mkdir build && cd build 
 cmake -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../** 

在执行 cmake 后我遇到了这个错误:

检测到架构“x86_64”

-- Using Python3 
 
    CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message): 
      Unable to find the requested Boost libraries. 
 
  Boost version: 1.59.0 
  Boost include path: /home/sumit/Documents/Software/boost_1_59_0 
  Could not find the following static Boost libraries: 
 
          boost_python3 
 
  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the 
  directory containing Boost libraries or BOOST_ROOT to the location of 
  Boost. 
Call Stack (most recent call first): 
  CMakeLists.txt:48 (find_package) 
 
 
 Boost Paths: 
Include  : /home/sumit/Documents/Software/boost_1_59_0 
 **Libraries**: /home/sumit/Documents/Software/boost_1_59_0/libs 
Configuring incomplete, errors occurred! 

另请参阅“/home/sumit/Documents/Software/Boost.NumPy/build/CMakeFiles/CMakeOutput.log”。

以前无法找到 boost 库 sp 我手动将 CmakeList.txt 库路径更改为 boost_1_59_0 库路径。当我执行 cmake 时,此路径出现在库选项中。但是仍然缺少 boost_python3。我是新手,我尝试的只是谷歌的结果。 请帮忙。

请您参考如下方法:

在 Ubuntu 上,boost 的库名称是: libboost_python、libboost_python-py35 或 libboost_python-py27

这意味着在 cmake 中,您需要将它们称为 python-py35 而不是 python3。或者,如果您不控制 CMakeLists.txt,您可以创建一个符号链接(symbolic link): /usr/lib/x86_64-linux-gnu/libboost_python-py35.so -> /usr/lib/x86_64-linux-gnu/libboost_python3.so

在我的 CMakeLists.txt 文件中,我有以下内容:

if(UNIX) 
    set( BOOST_PYTHONLIB python-py35) 
else() 
    set( BOOST_PYTHONLIB python3) 
endif() 
 
find_package (Boost 1.58 REQUIRED COMPONENTS 
    coroutine 
    context 
    filesystem 
    program_options 
    system 
    thread 
    ${BOOST_PYTHONLIB} 
    chrono 
    )