如何在macOS Sierra 10.12.3上安装适用于Python 3.6的openbabel [英] How to Install openbabel for Python 3.6 on macOS Sierra 10.12.3
问题描述
我正在使用Python编写脚本来处理博士中的某些化学结构.我想为python安装openbabel库.我已尽力而为,但无法在Windows上安装它.我之前在
I am using Python for making a script to work with some chemical structures in my PhD. I want to install openbabel libraries for python. I tried my best but I could not install it on Windows. I posted a question earlier about installing it on Windows at How do I install openbabel for Python 3.6 in Windows 10? but could not find a solution. The solution installed the library but it does not work and could not connect to SWIG. No I am trying to install it on my office computer which is a mac for past 5 hours but I could not figure what is going on. I tried to install it from source code of Opnbabel and link it with python3 but it is making problem. If I use the following command:
cmake ../ -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
它成功地将其链接到我不想要的Python 2.7.当我尝试以下选项时,它会显示以下错误:
It successfully links it to Python 2.7 which I do not want. When I try the following options, it gives the error shown below:
cmake ../ -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
OR
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
在大量成功输出之后,最终会出现以下错误:
It gives the following error at the end after a lot of successful output:
-- 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
但是,它也不能正常工作.
请帮助我,因为我需要此模块来进行研究.
谢谢
I am not sure why It detects the Python as v1.4 -- Found PythonInterp: /usr/bin/python3.6 (found version "1.4")
instead of finding v.3.5.
I tried all the procedure with python 3.6 as well but the same errors occur. I am also using the openbabel obtained from github which was said to be working with these commands at the following post: http://forums.openbabel.org/OpenBabel-for-Python-3-td4659432.html
But it doesn't work as well.
Please help me as I require this module for my research.
Thanks
推荐答案
我找到了解决方案.这是详细的解决方案:
I found the solution for that. Here is the detailed solution:
-
从原始来源下载Open Babel( https://github.com/openbabel/openbabel )
将其提取并cd进入(openbabel-master)
Extract it and cd into it (openbabel-master)
创建一个目录"build",并进入cd.
Make a directory "build" and cd into it.
运行以下命令:
cmake ../ -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
在上面的命令中,-DPYTHON_EXECUTABLE"开关告诉它找到Python3解释器的路径.您可以在终端上通过which python3
进行检查.
In the command above, the "-DPYTHON_EXECUTABLE" switch tells it the path where Python3 interpretor is found. You can check it by which python3
at a terminal.
make
make install
全部完成! :)
这篇关于如何在macOS Sierra 10.12.3上安装适用于Python 3.6的openbabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!