2

我正在使用 Python 制作一个脚本来处理我的博士学位中的一些化学结构。我想为 python 安装 openbabel 库。我尽力了,但我无法在 Windows 上安装它。我之前在如何在 Windows 10 中为 Python 3.6 安装 openbabel发布了一个关于在 Windows 上安装它的问题?但找不到解决方案。该解决方案安装了库,但它不起作用并且无法连接到 SWIG。不,我正在尝试将它安装在我的办公室计算机上,这是过去 5 个小时的 mac,但我不知道发生了什么。我尝试从 Opnbabel 的源代码安装它并将其与 python3 链接,但它出现了问题。如果我使用以下命令:

cmake ../ -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON

它成功地将它链接到我不想要的 Python 2.7。当我尝试以下选项时,它会给出如下所示的错误:

cmake ../ -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON

或者

cmake ../ -DRUN_SWIG=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib -DPYTHON_BINDINGS=ON

在大量成功输出后,最后会出现以下错误:

-- Found PythonInterp: /usr/bin/python3.6 (found version "1.4") 
-- Found SWIG: /usr/local/bin/swig (found version "3.0.12") 
-- Found SWIG: /usr/local/bin/swig (found suitable version "3.0.12", minimum required is "2.0") 
-- Found PythonLibs: /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib (found version "3.6.0") 
-- Python bindings will be compiled
CMake Error at scripts/CMakeLists.txt:120 (install):
install TARGETS given no LIBRARY DESTINATION for module target
"bindings_python".
CMake Error at scripts/CMakeLists.txt:123 (install):
install FILES given no DESTINATION!
CMake Error at scripts/CMakeLists.txt:126 (install):
install FILES given no DESTINATION!
-- Configuring incomplete, errors occurred!
See also "/usr/local/Cellar/obabel/openbabel-master/ali/CMakeFiles/CMakeOutput.log".
See also "/usr/local/Cellar/obabel/openbabel-master/ali/CMakeFiles/CMakeError.log".

我不确定为什么它将 Python 检测为 v1.4-- Found PythonInterp: /usr/bin/python3.6 (found version "1.4")而不是找到 v.3.5。我也用 python 3.6 尝试了所有过程,但发生了同样的错误。我还使用从 github 获得的 openbabel,据说在以下帖子中可以使用这些命令:http ://forums.openbabel.org/OpenBabel-for-Python-3-td4659432.html 但它不起作用也是。请帮助我,因为我需要此模块进行研究。谢谢

4

1 回答 1

3

我找到了解决方案。这是详细的解决方案:

  1. 从原始源下载 Open Babel ( https://github.com/openbabel/openbabel )

  2. 提取它并 cd 进入它(openbabel-master)

  3. 创建一个目录“build”并 cd 进入其中。

  4. 运行以下命令:

    cmake ../ -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON

    在上面的命令中,“-DPYTHON_EXECUTABLE”开关告诉它找到 Python3 解释器的路径。您可以which python3在终端检查它。

  5. make

  6. make install

全部完成!:)

于 2017-02-20T00:18:35.237 回答