J.Doe
J.Doe

Reputation: 464

Installing OpenBabel for Python isn't working

I have read all the related posts and they aren't helping. Like this one is just a defunct that leads nowhere. I have installed the binary for Windows form here and as I understood, I had to then use pip to install openbabel using:

pip install openbabel

But when I run that, I get the following error:

C:\Users\Chris>pip install openbabel
Collecting openbabel
  Using cached openbabel-3.1.1.1.tar.gz (82 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: openbabel
  Building wheel for openbabel (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for openbabel (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_ext
      Warning: invalid version number '3.1.1.1'.
      Guessing Open Babel location:
      - include_dirs: ['C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\Python39\\include', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\Python39\\Include', '/usr/local/include/openbabel3']
      - library_dirs: ['C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\Python39\\libs', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\Python39', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\Python39\\PCbuild\\amd64', '/usr/local/lib']
      building 'openbabel._openbabel' extension
      swigging openbabel\openbabel-python.i to openbabel\openbabel-python_wrap.cpp
      swig.exe -python -c++ -small -O -templatereduce -naturalvar -IC:\Users\Chris\AppData\Local\Programs\Python\Python39\include -IC:\Users\Chris\AppData\Local\Programs\Python\Python39\Include -I/usr/local/include/openbabel3 -o openbabel\openbabel-python_wrap.cpp openbabel\openbabel-python.i

      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/openbabel3 -L/usr/local/lib
        python setup.py install
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for openbabel
Failed to build openbabel
ERROR: Could not build wheels for openbabel, which is required to install pyproject.toml-based projects

So naturally, when I try to import pybel from openbabel in my script, it's not found.

It says that I need to "build wheels". I do not know what that means, or even what wheels are supposed to be.

All I saw in regards to that was that I was supposed to download some file from this link according to this github issue. But I am slightly out of my depth here. Which one of the 10 openbabel.whks am I supposed to get? I just downloaded the first one since it seemed like a recent version and it said amd64 (I have a ryzen CPU in my system). I installed openbabel using the installer, ran the .whk and then tried to run pip install openbabel. Same nothing...

I have no idea how to fix this and it's been a long running issue. Openbabel would be very useful to me, were I able to utilize it in my scripts. So please, tell me how to get it working.

Upvotes: 2

Views: 1681

Answers (1)

JUN
JUN

Reputation: 1

Try "pip install SWIG" then install openbabel

Upvotes: 0

Related Questions