我正在使用Python制作一个脚本来处理我博士的一些化学结构。我想为python安装openbabel库。我尽我所能,但我无法安装它。它总是给出错误:
Error: SWIG failed. Is Open Babel installed?
这是我PC上的Python路径:C:\Users\malih\AppData\Local\Programs\Python\Python36-32
。 Openbabel安装在以下路径C:\Program Files (x86)\OpenBabel-2.3.1
。
当我运行python -m pip install openbabel
时,它会出现以下错误:
C:\Users\malih>python -m pip install openbabel
Collecting openbabel
Using cached openbabel-2.4.1.tar.gz
Installing collected packages: openbabel
Running setup.py install for openbabel ... error
Complete output from command C:\Users\malih\AppData\Local\Programs\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\malih\\AppData\\Local\\Temp\\pip-build-glr82a7x\\openbabel\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\malih\AppData\Local\Temp\pip-02z3p_a9-record\install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
Warning: pkg-config could not be found.
Guessing Open Babel location:
- include_dirs: ['C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\include', 'C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\include', '/usr/local/include/openbabel-2.0']
- library_dirs: ['C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\libs', 'C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\PCbuild\\win32', '/usr/local/lib']
building '_openbabel' extension
swigging openbabel-python.i to openbabel-python_wrap.cpp
swig.exe -python -c++ -small -O -templatereduce -naturalvar -IC:\Users\malih\AppData\Local\Programs\Python\Python36-32\include -IC:\Users\malih\AppData\Local\Programs\Python\Python36-32\include -I/usr/local/include/openbabel-2.0 -o openbabel-python_wrap.cpp openbabel-python.i
Error: SWIG failed. Is Open Babel installed?
You may need to manually specify the location of Open Babel include and library directories. For example:
python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib
python setup.py install
----------------------------------------
Command "C:\Users\malih\AppData\Local\Programs\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\malih\\AppData\\Local\\Temp\\pip-build-glr82a7x\\openbabel\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\malih\AppData\Local\Temp\pip-02z3p_a9-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\malih\AppData\Local\Temp\pip-build-glr82a7x\openbabel\
我尝试按照此页面上的说明操作,但它们纯粹是针对Linux的,我无法跟进它们的Windows: How do I use python-openbabel in Travis CI?
我还尝试从以下指南安装pkg-config,但即便如此,它也会出现同样的错误: How to install pkg config in windows?
请帮我解决这个问题,因为我的工作是以此为基础的,我现在陷入困境。提前感谢您的时间。
答案 0 :(得分:1)
pip install
不友好。要么去openbabel网站并下载+安装windows二进制文件,然后下载+安装python绑定,或者使用unoffical official openbabel python windows build,然后使用cd
进入下载的目录,并执行pip install OPENBABEL_FILE_WINDOWS.whl
我最近在2D mol文件上做了一些相当多的工作 - >使用openbabel的3D mol文件翻译。让我知道它是如何为你工作的。
-
编辑:我还应该补充一点,python3.x与python2.x完全不同。因此,如果有任何问题,请尝试使用python2.x