我在尝试导入pybel modu时遇到AttributeError

2024-04-30 04:50:43 发布

您现在位置:Python中文网/ 问答频道 /正文

参考以下说明: http://open-babel.readthedocs.io/en/latest/UseTheLibrary/Python_Pybel.html

http://openbabel.org/wiki/Category:Installation安装了windows 64位版本的OpenBabel2.4.1之后,我通过pip安装了Openbabel和pybel。在

>>>pip install pybel
>>>pip install openbabel

我试图以sdf格式(文件名为mol1.sdf存在于同一目录中)来查找分子的分子量

python文件(测试.py)我创造了如下:

^{pr2}$

以下是命令提示符中发生的情况:

>>> python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
mol = pybel.readfile("sdf", "mol1.sdf").next()
AttributeError: 'module' object has no attribute 'readfile'

但是根据上面参考链接中的示例代码,有一个名为“readfile”的属性可以读取文件和格式。我错过什么了吗?谢谢


Tags: installpip文件pytesthttp格式open