Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: libodbc.so.2: cannot open shared object file: No such file or directory

After installing pyodbc in a docker container I'm receiving the error:

  File "/root/.local/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py", line 43, in dbapi
    return __import__("pyodbc")
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory

Any solution around this?

I tried uninstalling and reinstalling but no luck.

like image 454
David D'Silva Avatar asked Feb 03 '26 20:02

David D'Silva


2 Answers

You need to install libodbc.so.2 on your system. The easiest way to do this is through your system's package manager.

For a Red Hat based distro, run: sudo yum install unixODBC

For a Debian based distro, run: sudo apt install unixodbc

like image 83
cyberoptic Avatar answered Feb 06 '26 08:02

cyberoptic


For me, the solution to solve this problem was:

sudo apt remove libodbc2
sudo apt install libodbc2

I am using a distro based on Ubuntu 22.04 LTS (Jammy)

like image 22
Johni Douglas Marangon Avatar answered Feb 06 '26 08:02

Johni Douglas Marangon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!