('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")

See original GitHub issue

Hi guys, I already had a look at previous similar issues but I could not find a proper solution. I am using a Jupyter notebook on Azure ML compute instance. I am trying to connect an Azure SQL database using pyodbc but I get below error: _(‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘ODBC Driver 17 for SQL Server’ : file not found (0) (SQLDriverConnect)”)_

My code:

import pyodbc
server = 'tcp:xxx.database.windows.net'
database = 'xxxx'
username = 'xxx'
password = 'xxxxx'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()

Environment

  • Kernel: Python 3.6 Azure ML
  • Python: 3.6.9 |Anaconda, Inc. [GCC 7.3.0]
  • pyodbc: 4.0.27
  • OS: 16.04.6 LTS (Xenial Xerus)
  • DB: Azure SQL
  • driver: ODBC Driver 17 for SQL

Issue

Expected behaviour: I expect to have a successfull connection, Observerd behaviour: No connection to the DB because it can not locate ODBC Driver 17 for SQL.

Extra information from similar questions online: 1- There is no microsoft folder in /opt folder (referring this question and solutions) 2- There is no odbcinst file in /etc folder (referring this question and solutions) 3- When I try pyodbc.drivers() it returns an empty array. (I uninstalled and reinstalled pyodbc, I am able to import it.) 4- I can not locate msodbcsql17 (referring here) 4- I tried ODBC Driver 13 as well, same problem exists.

Any help will be appreciated!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:33 (7 by maintainers)

github_iconTop GitHub Comments

18reactions
gordthompsoncommented, Feb 27, 2020

Did you actually install the driver as per the instructions here?

8reactions
gordthompsoncommented, Sep 27, 2020

@gabraham00 - If pyodbc.drivers() is returning an empty list then your unixODBC is not configured correctly. It should look like this:

gord@vbox-Xubu-20-04-a:~$ odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/gord/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
gord@vbox-Xubu-20-04-a:~$ cat /etc/odbcinst.ini
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.6.so.1.1
UsageCount=1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't open lib 'ODBC Driver 13 for SQL Server'? Sym linking ...
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libmsodbcsql.13.dylib' : file not found (0) ...
Read more >
Error ('01000', [01000] [unixODBC][Driver Manager]Can't open ...
If you get the Error ('01000', [01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect))...
Read more >
Azure RHEL 8 VM. pyodbc or django can't connect to SQL ...
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib ... file not found (0) (SQLDriverConnect)"). I'm on an Azure RHEL 8 VM trying ...
Read more >
can't open lib 'odbc driver 18 for sql server' : file not found (0 ...
The error is showing: Error: (01000, "[01000] [unixODBC] [Driver Manager] Can't open lib 'SQL Server: file not found (0) (SQLDriverConnect)").
Read more >
"pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager ...
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found