0

我正在尝试在没有 root 访问权限并使用虚拟环境的 linux 计算机上openbabel安装。pip我运行以下命令

pip install openbabel --user --log LOG

然后我收到以下错误:

Collecting openbabel
  Using cached openbabel-2.4.1.tar.gz (74 kB)
Building wheels for collected packages: openbabel
  Building wheel for openbabel (setup.py) ... error
  ERROR: Failed building wheel for openbabel
  Running setup.py clean for openbabel
Failed to build openbabel
Installing collected packages: openbabel
    Running setup.py install for openbabel ... error
ERROR: Command errored out with exit status 1: /users/name/env_for_pymatgen/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b51wnefv/openbabel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b51wnefv/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 /tmp/pip-record-4207icvx/install-record.txt --single-version-externally-managed --compile --install-headers /users/name/env_for_pymatgen/include/site/python3.6/openbabel Check the logs for full command output.

主要问题似乎是

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

我看到很多人有类似的问题,setup.py建议他们转到目录并再次运行相同的命令,但我不知道我应该转到哪个目录...

编辑

如果我从 github 下载 openbabel 并给出它的路径,它会起作用吗?

4

1 回答 1

0

根据我的经验,请从此处pip install <package_name>下载一个 wheel 文件, 该文件具有从 PyPI 上的源代码构建的 python 二进制文件。

之后,打开下载.whl文件的终端,然后键入:

pip install nameOfYourFile.whl

就我而言,它是:

pip install openbabel-3.1.1-cp38-cp38-win32.whl

编辑:请务必下载与您的 python 版本匹配的版本,否则该软件包将无法安装。

EDIT2:老实说,我没有注意到答案集中在 Linux 上,所以要回答你的问题,你最可靠的选择是从源代码构建它并启用 python 绑定和 swig 标志,这可以通过遵循编译说明来完成.

截至本次编辑之日,这些说明仍然适用于 GitHub 存储库中最新版本的 openbabel,并且我可以在 Ubuntu 21.10 上使用 python 绑定 (pybel) 成功编译一个可用的 openbabel。

于 2021-05-11T02:54:27.623 回答