first, I should say to you that I use ubuntu on wsl2 in a windows 10, then I installed sql server on windows 10.
then used blow commands to install pyodb:
sudo apt install python3-pyodbc

sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 20.04
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /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

after, I create tesrt.py and put the following code on it:

import pyodbc

conn = pyodbc.connect('Driver={ODBC Driver 17 for SQL Server};'

I ran this app, at the end I gave this error:

pyodbc.OperationalError: (‘HYT00’, ‘[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)’)

I don’t have any idea but I connected to that with sqlcmd:
Sqlcmd -S HQ-PC-059KAISQL -U sa -P pass
thank you <3