Unable to import pybel in Python

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unable to import pybel in Python

Dan Smith
Hello,

I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating system. 

I have installed eigen2.  I have python version 2.7.10.

I have successfully compiled version 2.3.90 using the following commands in terminal.

cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH


When I attempt to import pybel or openbabel in Python I get the following messages.

>>> import pybel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pybel

>>> import openbabel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named openbabel

I have tried to search previous posts but have not found an answer that will solve my problem. At this point I’m not sure what to do to diagnose the problem.

Any help in solving my problem would be appreciated.

Thanks,

Dan

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Leonardo Lazzaro
Hello,

try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
for example for anaconda2 I used the following command:

cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
-DCMAKE_INSTALL_PREFIX=~/anaconda2
-DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
-DCMAKE_LIBRARY_PATH=~/anaconda2/lib
-DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
-DSWIG_EXECUTABLE=~/anaconda2/bin/swig
-DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
-DCMAKE_BUILD_TYPE=DEBUG

hope it helps,
Leonardo

On 2016-07-07 17:23, Dan Smith wrote:

> Hello,
>
> I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
> system.
>
> I have installed eigen2. I have python version 2.7.10.
>
> I have successfully compiled version 2.3.90 using the following
> commands in terminal.
>
> cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
> make
> sudo make install
> export PYTHONPATH=/usr/local/lib:$PYTHONPATH
>
> When I attempt to import pybel or openbabel in Python I get the
> following messages.
>
>>>> import pybel
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ImportError: No module named pybel
>
>>>> import openbabel
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ImportError: No module named openbabel
>
> I have tried to search previous posts but have not found an answer
> that will solve my problem. At this point I’m not sure what to do to
> diagnose the problem.
>
> Any help in solving my problem would be appreciated.
>
> Thanks,
>
> Dan
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech
> luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Chris Swain
In reply to this post by Dan Smith
Hi,

I’ve written a page on installing cheminformatics tools on a Mac, here http://www.macinchem.org/reviews/cheminfo/cheminfoMac.php

Cheers,

Chris

On 8 Jul 2016, at 13:05, [hidden email] wrote:

Message: 1
Date: Thu, 7 Jul 2016 15:23:02 -0500
From: Dan Smith <[hidden email]>
Subject: [Open Babel] Unable to import pybel in Python
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello,

I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating system. 

I have installed eigen2.  I have python version 2.7.10.

I have successfully compiled version 2.3.90 using the following commands in terminal.

cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH


When I attempt to import pybel or openbabel in Python I get the following messages.

import pybel
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named pybel

import openbabel
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named openbabel

I have tried to search previous posts but have not found an answer that will solve my problem. At this point I?m not sure what to do to diagnose the problem.

Any help in solving my problem would be appreciated.

Thanks,

Dan


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Dan Smith
In reply to this post by Leonardo Lazzaro
Leonardo, thanks for the suggestion.

 I tried the DPYTHON_INCLUDE_DIR option shown below.

cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON -DPYTHON_INCLUDE_DIR=~/usr/include/python2.7

make failed with the following error.

/Users/dansmith/Documents/MOLECULAR_MODELING/OpenBabel/openbabel/scripts/python/openbabel-python.cpp:174:11: fatal error: 
      'Python.h' file not found
# include <Python.h>
          ^
1 error generated.

In the original build attempt without the  DPYTHON_INCLUDE_DIR option.  There were 3 warnings at the same point shown below and several messages.

I’m not sure why my implementation of your suggestion fails as I verified that Python.h could be found in /usr/include/python2.7; however, after closer inspection of the “sudo make install” output I believe I have discovered part of the problem.  I tried the original installation method.

cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON 
make
sudo make install

The output from “sudo make install” for openbabel.py and pybel.py is shown below.

-- Installing: /usr/local/lib/python2.7/site-packages/_openbabel.so
-- Up-to-date: /usr/local/lib/python2.7/site-packages/openbabel.py
-— Up-to-date: /usr/local/lib/python2.7/site-packages/pybel.py

I set the python path as follows.

export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH

Importing pybel and openbabel works now. I tried to work through some of the examples on the web (http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html).  The examples do not work exactly as written.  For instance, I cannot use the command “read string”, but I can use “pybel.readstring”.

>>> mymol = readstring("smi", "CCCC")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'readstring' is not defined
>>> mymol = pybel.readstring("smi", "CCCC")
>>> print mymol.molwt
58.1222

Is this normal or is there something wrong with my installation?

Thanks,

Dan


On Jul 7, 2016, at 6:01 PM, Leonardo Lazzaro <[hidden email]> wrote:

Hello,

try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
for example for anaconda2 I used the following command:

cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
-DCMAKE_INSTALL_PREFIX=~/anaconda2
-DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
-DCMAKE_LIBRARY_PATH=~/anaconda2/lib
-DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
-DSWIG_EXECUTABLE=~/anaconda2/bin/swig
-DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
-DCMAKE_BUILD_TYPE=DEBUG

hope it helps,
Leonardo

On 2016-07-07 17:23, Dan Smith wrote:
Hello,

I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
system.

I have installed eigen2. I have python version 2.7.10.

I have successfully compiled version 2.3.90 using the following
commands in terminal.

cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH

When I attempt to import pybel or openbabel in Python I get the
following messages.

import pybel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pybel

import openbabel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named openbabel

I have tried to search previous posts but have not found an answer
that will solve my problem. At this point I’m not sure what to do to
diagnose the problem.

Any help in solving my problem would be appreciated.

Thanks,

Dan
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech
luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Noel O'Boyle
Administrator
Your INCLUDE_DIR has a ~. This means your home directory.

On 8 July 2016 at 16:14, Dan Smith <[hidden email]> wrote:

> Leonardo, thanks for the suggestion.
>
>  I tried the DPYTHON_INCLUDE_DIR option shown below.
>
> cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
> -DPYTHON_INCLUDE_DIR=~/usr/include/python2.7
>
> make failed with the following error.
>
> /Users/dansmith/Documents/MOLECULAR_MODELING/OpenBabel/openbabel/scripts/python/openbabel-python.cpp:174:11:
> fatal error:
>       'Python.h' file not found
> # include <Python.h>
>           ^
> 1 error generated.
>
> In the original build attempt without the  DPYTHON_INCLUDE_DIR option.
> There were 3 warnings at the same point shown below and several messages.
>
> I’m not sure why my implementation of your suggestion fails as I verified
> that Python.h could be found in /usr/include/python2.7; however, after
> closer inspection of the “sudo make install” output I believe I have
> discovered part of the problem.  I tried the original installation method.
>
> cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
> make
> sudo make install
>
> The output from “sudo make install” for openbabel.py and pybel.py is shown
> below.
>
> -- Installing: /usr/local/lib/python2.7/site-packages/_openbabel.so
> -- Up-to-date: /usr/local/lib/python2.7/site-packages/openbabel.py
> -— Up-to-date: /usr/local/lib/python2.7/site-packages/pybel.py
>
> I set the python path as follows.
>
> export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
>
> Importing pybel and openbabel works now. I tried to work through some of the
> examples on the web
> (http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html).  The
> examples do not work exactly as written.  For instance, I cannot use the
> command “read string”, but I can use “pybel.readstring”.
>
>>>> mymol = readstring("smi", "CCCC")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'readstring' is not defined
>>>> mymol = pybel.readstring("smi", "CCCC")
>>>> print mymol.molwt
> 58.1222
>
> Is this normal or is there something wrong with my installation?
>
> Thanks,
>
> Dan
>
>
> On Jul 7, 2016, at 6:01 PM, Leonardo Lazzaro <[hidden email]> wrote:
>
> Hello,
>
> try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
> for example for anaconda2 I used the following command:
>
> cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
> -DCMAKE_INSTALL_PREFIX=~/anaconda2
> -DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
> -DCMAKE_LIBRARY_PATH=~/anaconda2/lib
> -DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
> -DSWIG_EXECUTABLE=~/anaconda2/bin/swig
> -DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
> -DCMAKE_BUILD_TYPE=DEBUG
>
> hope it helps,
> Leonardo
>
> On 2016-07-07 17:23, Dan Smith wrote:
>
> Hello,
>
> I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
> system.
>
> I have installed eigen2. I have python version 2.7.10.
>
> I have successfully compiled version 2.3.90 using the following
> commands in terminal.
>
> cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>
> make
>
> sudo make install
> export PYTHONPATH=/usr/local/lib:$PYTHONPATH
>
> When I attempt to import pybel or openbabel in Python I get the
> following messages.
>
> import pybel
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named pybel
>
> import openbabel
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named openbabel
>
> I have tried to search previous posts but have not found an answer
> that will solve my problem. At this point I’m not sure what to do to
> diagnose the problem.
>
> Any help in solving my problem would be appreciated.
>
> Thanks,
>
> Dan
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech
> luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

David Hall
In reply to this post by Dan Smith
The below is dependent on how you import pybel

you did "import pybel", which imports the pybel functions with a "pybel." prefix as shown in your efforts to run things.

Some of the examples in the documentation implicitly do "from pybel import *" so the functions are imported without a prefix.

-David

On Jul 8, 2016, at 11:14 AM, Dan Smith <[hidden email]

Importing pybel and openbabel works now. I tried to work through some of the examples on the web (http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html).  The examples do not work exactly as written.  For instance, I cannot use the command “read string”, but I can use “pybel.readstring”.

>>> mymol = readstring("smi", "CCCC")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'readstring' is not defined
>>> mymol = pybel.readstring("smi", "CCCC")
>>> print mymol.molwt
58.1222

Is this normal or is there something wrong with my installation?

Thanks,

Dan


On Jul 7, 2016, at 6:01 PM, Leonardo Lazzaro <[hidden email]> wrote:

Hello,

try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
for example for anaconda2 I used the following command:

cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
-DCMAKE_INSTALL_PREFIX=~/anaconda2
-DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
-DCMAKE_LIBRARY_PATH=~/anaconda2/lib
-DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
-DSWIG_EXECUTABLE=~/anaconda2/bin/swig
-DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
-DCMAKE_BUILD_TYPE=DEBUG

hope it helps,
Leonardo

On 2016-07-07 17:23, Dan Smith wrote:
Hello,

I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
system.

I have installed eigen2. I have python version 2.7.10.

I have successfully compiled version 2.3.90 using the following
commands in terminal.

cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH

When I attempt to import pybel or openbabel in Python I get the
following messages.

import pybel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pybel

import openbabel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named openbabel

I have tried to search previous posts but have not found an answer
that will solve my problem. At this point I’m not sure what to do to
diagnose the problem.

Any help in solving my problem would be appreciated.

Thanks,

Dan
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech
luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Dan Smith
In reply to this post by Noel O'Boyle
Yes.  Thank you.

> On Jul 8, 2016, at 10:33 AM, Noel O'Boyle <[hidden email]> wrote:
>
> Your INCLUDE_DIR has a ~. This means your home directory.
>
> On 8 July 2016 at 16:14, Dan Smith <[hidden email]> wrote:
>> Leonardo, thanks for the suggestion.
>>
>> I tried the DPYTHON_INCLUDE_DIR option shown below.
>>
>> cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>> -DPYTHON_INCLUDE_DIR=~/usr/include/python2.7
>>
>> make failed with the following error.
>>
>> /Users/dansmith/Documents/MOLECULAR_MODELING/OpenBabel/openbabel/scripts/python/openbabel-python.cpp:174:11:
>> fatal error:
>>      'Python.h' file not found
>> # include <Python.h>
>>          ^
>> 1 error generated.
>>
>> In the original build attempt without the  DPYTHON_INCLUDE_DIR option.
>> There were 3 warnings at the same point shown below and several messages.
>>
>> I’m not sure why my implementation of your suggestion fails as I verified
>> that Python.h could be found in /usr/include/python2.7; however, after
>> closer inspection of the “sudo make install” output I believe I have
>> discovered part of the problem.  I tried the original installation method.
>>
>> cmake ../openbabel  -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>> make
>> sudo make install
>>
>> The output from “sudo make install” for openbabel.py and pybel.py is shown
>> below.
>>
>> -- Installing: /usr/local/lib/python2.7/site-packages/_openbabel.so
>> -- Up-to-date: /usr/local/lib/python2.7/site-packages/openbabel.py
>> -— Up-to-date: /usr/local/lib/python2.7/site-packages/pybel.py
>>
>> I set the python path as follows.
>>
>> export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
>>
>> Importing pybel and openbabel works now. I tried to work through some of the
>> examples on the web
>> (http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html).  The
>> examples do not work exactly as written.  For instance, I cannot use the
>> command “read string”, but I can use “pybel.readstring”.
>>
>>>>> mymol = readstring("smi", "CCCC")
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in <module>
>> NameError: name 'readstring' is not defined
>>>>> mymol = pybel.readstring("smi", "CCCC")
>>>>> print mymol.molwt
>> 58.1222
>>
>> Is this normal or is there something wrong with my installation?
>>
>> Thanks,
>>
>> Dan
>>
>>
>> On Jul 7, 2016, at 6:01 PM, Leonardo Lazzaro <[hidden email]> wrote:
>>
>> Hello,
>>
>> try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
>> for example for anaconda2 I used the following command:
>>
>> cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>> -DCMAKE_INSTALL_PREFIX=~/anaconda2
>> -DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
>> -DCMAKE_LIBRARY_PATH=~/anaconda2/lib
>> -DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
>> -DSWIG_EXECUTABLE=~/anaconda2/bin/swig
>> -DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
>> -DCMAKE_BUILD_TYPE=DEBUG
>>
>> hope it helps,
>> Leonardo
>>
>> On 2016-07-07 17:23, Dan Smith wrote:
>>
>> Hello,
>>
>> I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
>> system.
>>
>> I have installed eigen2. I have python version 2.7.10.
>>
>> I have successfully compiled version 2.3.90 using the following
>> commands in terminal.
>>
>> cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>>
>> make
>>
>> sudo make install
>> export PYTHONPATH=/usr/local/lib:$PYTHONPATH
>>
>> When I attempt to import pybel or openbabel in Python I get the
>> following messages.
>>
>> import pybel
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> ImportError: No module named pybel
>>
>> import openbabel
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> ImportError: No module named openbabel
>>
>> I have tried to search previous posts but have not found an answer
>> that will solve my problem. At this point I’m not sure what to do to
>> diagnose the problem.
>>
>> Any help in solving my problem would be appreciated.
>>
>> Thanks,
>>
>> Dan
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech
>> luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>
>>
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to import pybel in Python

Dan Smith
In reply to this post by David Hall
Thank you sir.  I used “import pybel”.  I did not realize the difference in “from pybel import*”.  I’m learning how to use python now.

Looks like all is working.

Dan


On Jul 8, 2016, at 10:55 AM, David Hall <[hidden email]> wrote:

The below is dependent on how you import pybel

you did "import pybel", which imports the pybel functions with a "pybel." prefix as shown in your efforts to run things.

Some of the examples in the documentation implicitly do "from pybel import *" so the functions are imported without a prefix.

-David

On Jul 8, 2016, at 11:14 AM, Dan Smith <[hidden email]

Importing pybel and openbabel works now. I tried to work through some of the examples on the web (http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html).  The examples do not work exactly as written.  For instance, I cannot use the command “read string”, but I can use “pybel.readstring”.

>>> mymol = readstring("smi", "CCCC")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'readstring' is not defined
>>> mymol = pybel.readstring("smi", "CCCC")
>>> print mymol.molwt
58.1222

Is this normal or is there something wrong with my installation?

Thanks,

Dan


On Jul 7, 2016, at 6:01 PM, Leonardo Lazzaro <[hidden email]> wrote:

Hello,

try to use the options DPYTHON_INCLUDE_DIR, DCMAKE_INSTALL_PREFIX.
for example for anaconda2 I used the following command:

cmake .. -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
-DCMAKE_INSTALL_PREFIX=~/anaconda2
-DPYTHON_INCLUDE_DIR=~/anaconda2/include/python2.7
-DCMAKE_LIBRARY_PATH=~/anaconda2/lib
-DSWIG_DIR=~/anaconda2/share/swig/3.0.2/
-DSWIG_EXECUTABLE=~/anaconda2/bin/swig
-DPYTHON_LIBRARY=~/anaconda2/lib/libpython2.7.so
-DCMAKE_BUILD_TYPE=DEBUG

hope it helps,
Leonardo

On 2016-07-07 17:23, Dan Smith wrote:
Hello,

I am using openbabel on a Mac - El Capitan OS X 10.11.5 operating
system.

I have installed eigen2. I have python version 2.7.10.

I have successfully compiled version 2.3.90 using the following
commands in terminal.

cmake ../openbabel -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH

When I attempt to import pybel or openbabel in Python I get the
following messages.

import pybel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pybel

import openbabel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named openbabel

I have tried to search previous posts but have not found an answer
that will solve my problem. At this point I’m not sure what to do to
diagnose the problem.

Any help in solving my problem would be appreciated.

Thanks,

Dan
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech
luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Loading...