Closed dxk5271 closed 1 year ago
What errors, specifically?
"ImportError: libodbc.so.2: cannot open shared object file: No such file or directory"
I did confirm that pyodbc did exists. Downgrading to 4.0.34 resolved this issue.
Install unixODBC.
4.0.34 came with unixODBC but it is a very old and buggy version which has caused other issues here.
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)
this made the trick !
sudo apt-get install unixodbc-dev
this made the trick !
sudo apt-get install unixodbc-dev
It's works for python:3.9-bullseye well ! THX
If you encounter the ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
error when trying to import pyodbc after installing it via pip, follow these steps:
Install unixODBC: Run the following command to install unixODBC, which is required for pyodbc to work properly.
$ sudo apt install unixodbc
This should resolve the shared object file error and allow you to use pyodbc without any issues.
Do you really need to repeat what was said multiple times in previous comments already?
i was trying to connect to SQL Server database from a django application, but I was facing this error, so the way I solved it was
unixodbc
First, ensure you have unixodbc
installed. You can install it using the following command:
sudo apt install unixodbc
Run the following bash script to install the Microsoft ODBC 17 Driver:
if ! [[ "16.04 18.04 20.04 22.04" == *"$(lsb_release -rs)"* ]];
then
echo "Ubuntu $(lsb_release -rs) is not currently supported.";
exit;
fi
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev
Pyodbc successfully installs in my Kubernetes container through a requirments.txt file. But I receive errors when importing pyodbc in my python script.
Downgrading to the previous version fixed this issue.