A useful command is dir(pybel), or help(pybel). I think you want
"import openbabel as ob", and ob.OBMol() etc.

On 9 August 2017 at 05:53, Kohsei Tsuji
<k-ts...@mail.cstm.kyushu-u.ac.jp> wrote:
> Dear all,
>
> I am using openbabel 2.4.1 (with python building) on OS X Yosemite 10.10.5
> and python 2.7.10.
> I have successfully installed openbabel using homebrew, and checked pybel
> module was correctly imported in python without any error.
> Then, I tried to run the following python script (sample.py) to test pybel
> module properly works.
>
> import pybel
> mol = pybel.OBMol()
> conv = pybel.OBConversion()
> conv.SetInAndOutFormats("smi","mdl")
> conv.ReadString(mol,"c1ccccc1O")
> print mol.NumAtoms()
> mol.AddHydrogens()
> print mol.NumAtoms()
> conv.WriteFile(mol,'phenol.mol')
>
> but when I tried to run this script I got the attribute error as follows.
>
> Traceback (most recent call last):
>   File "/Users/kohseitsuji/Desktop/sample.py", line 2, in <module>
>     mol = pybel.OBMol()
> AttributeError: 'module' object has no attribute 'OBMol'
>
> I’m not sure why this error happens since I could import the pybel module in
> python.
>
> How can I fix this error?  Any help would be highly appreciated.
>
> Thank you
>
>
>
>
> --
> View this message in context: 
> http://forums.openbabel.org/Pybel-attribute-error-tp4660180.html
> Sent from the General discussion mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to