Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 7102  / 2 Years ago, mon, april 4, 2022, 4:35:59

On Chemistry Stack Exchange I asked a question regarding Open Babel & Python being used together.


The problem is that the answer I was provided (by Geoff Hutchinson) requires Python to be able to import the module Pybel.


I have installed Open Babel on this PC via two ways, APT and source. I then deleted my APT installation after I realized pybel wasn't available for Python use and I decided to install from source with Python bindings.


To do so I followed this guide with the final command being customized to (running from ~/build)


cmake ../openbabel-2.3.2 -DBUILD_GUI=ON -DPYTHON_BINDINGS=ON

which gave the output:


-- Using included inchi library.
-- Found wxWidgets: TRUE
-- Cairo found. PNG output will be supported.
-- Attempting to build the GUI
-- wxWidgets found => GUI will be built
CMake Warning (dev) at test/CMakeLists.txt:171 (include):
Syntax Warning in cmake code at

/home/fusion809/Downloads/openbabel-2.3.2/cmake/modules/UsePythonTest.cmake:54:14

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at test/CMakeLists.txt:171 (include):
Syntax Warning in cmake code at

/home/fusion809/Downloads/openbabel-2.3.2/cmake/modules/UsePythonTest.cmake:54:31

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at test/CMakeLists.txt:171 (include):
Syntax Warning in cmake code at

/home/fusion809/Downloads/openbabel-2.3.2/cmake/modules/UsePythonTest.cmake:57:25

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at test/CMakeLists.txt:171 (include):
Syntax Warning in cmake code at

/home/fusion809/Downloads/openbabel-2.3.2/cmake/modules/UsePythonTest.cmake:57:39

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Python bindings will be compiled
-- Could NOT find Ruby (missing: RUBY_INCLUDE_DIR RUBY_LIBRARY RUBY_CONFIG_INCLUDE_DIR) (found version "2.1.0")
-- Ruby library files NOT found. Ruby bindings will NOT be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fusion809/build

I should mention, however, that the first time I compiled Open Babel I forgot to add the -DBUILD_GUI & -DPYTHON_BINDINGS commands to the cmake line, so I had to run this new cmake command after I had initially compiled the software. Does this make any difference? Should I remove Open Babel and re-compile? If so do I have to delete some files in my /usr/ directory to (if so please mention them as I don't know which ones)? If relevant I am on 32 bit 15.04.


EDIT


I deleted my build directory's contents & started again and after the cmake command I ran:


make
sudo make install
export PYTHONPATH=/usr/local/lib:$PYTHONPATH

At the end of the output I received were these two lines:


-- Up-to-date: /usr/local/lib/openbabel.py
-- Up-to-date: /usr/local/lib/pybel.py

In a Python terminal I ran import openbabel and import pybel and it gave the output: ImportError: No module named ... where ... is openbabel or pybel, depending on which of the commands were executed, so I suspect it's a problem on my Python installation's end.


More From » python

 Answers
3

Without python-openbabel:



% python
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openbabel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named openbabel
>>>

% python
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pybel
>>>


Install python-openbabel:



sudo apt-get install python-openbabel


Check:



% python  
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openbabel
>>>

% python
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybel
>>>

[#19989] Monday, April 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
warrdel

Total Points: 356
Total Questions: 103
Total Answers: 118

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
;