pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libmyodbc8a.so' : file not found (0) (SQLDriverConnect)")

Open silverlightjashmin opened this issue 1 year ago • 6 comments

i am aable to connect the same db using the odbc driver with isql but i am unable to connect using pyodbc.

silverlightjashmin avatar Feb 06 '24 13:02 silverlightjashmin

Which OS is this? If isql works and pyodbc doesn't suggests they maybe using different drivers, if driver manager can open one but not the other. Which driver did you specify in isql?

v-makouz avatar Feb 06 '24 20:02 v-makouz

i am using ubuntu 20.04 os and i had called same driver for both isql and pyodbc.

silverlightjashmin avatar Feb 07 '24 04:02 silverlightjashmin

my odbcinst.ini files has

[ODBC Driver 17 for SQL Server] Description=Microsoft ODBC Driver 17 for SQL Server Driver=/usr/lib/libmsodbcsql-17.so UsageCount=1

[ODBC Driver For MySQL] Description=ODBC Driver For MySQL Driver=/usr/lib/x86_64-linux-gnu/libmyodbc8a.so UsageCount=1

[mysql] Driver=/usr/lib/x86_64-linux-gnu/libmyodbc8a.so UsageCount=1

[MySQL ODBC 8.3 Unicode Driver] DRIVER=/usr/local/lib/libmyodbc8w.so UsageCount=1

[MySQL ODBC 8.3 ANSI Driver] DRIVER=/usr/local/lib/libmyodbc8a.so UsageCount=1

and odbc.ini has

[test] Driver=mysql SERVER=10.10.13.7 USER=root PASSWORD=Super@dm1n DATABASE=backoffice PORT=3306 now when i use isql test, db connection is successful and when i am calling same driver from pyodbc, it gives me pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libmyodbc8a.so' : file not found (0) (SQLDriverConnect)") error.

silverlightjashmin avatar Feb 07 '24 04:02 silverlightjashmin

I don't know if that is helpful, but I had pretty much the same issue and somehow got it working now. Though, first isql wasn't working, too. But after I did install one additional library package and also did set LD_LIBRARY_PATH correctly for the driver, isql was working. Pyodbc still not.

I then checked the installed version of pyodbc, which was 5.1.0 (installed yesterday via pip) and tried to downgrade it to 4.0.93. Then it suddenly worked. But strangely, after upgrading pyodbc again, first to 5.0.1 and then to 5.1.0, it still works. This confuses me… I don't think I have done anything other than using "pip install" between the last unsuccessful and the later successful tests...

hurzhurz avatar Feb 07 '24 16:02 hurzhurz

I don't know if that is helpful, but I had pretty much the same issue and somehow got it working now. Though, first isql wasn't working, too. But after I did install one additional library package and also did set LD_LIBRARY_PATH correctly for the driver, isql was working. Pyodbc still not.

I then checked the installed version of pyodbc, which was 5.1.0 (installed yesterday via pip) and tried to downgrade it to 4.0.93. Then it suddenly worked. But strangely, after upgrading pyodbc again, first to 5.0.1 and then to 5.1.0, it still works. This confuses me… I don't think I have done anything other than using "pip install" between the last unsuccessful and the later successful tests...

What was the one additional library package that you installed? isql isn't working for me too.

gokul-ramasamy avatar Feb 28 '24 18:02 gokul-ramasamy

What was the one additional library package that you installed? isql isn't working for me too.

I'm not sure anymore, but I think in my case it was one of those: libaio1, libodbc2, libodbcinst2 But that could depend on which ODBC driver you want to use.

Best is to check with ldd /path/to/odbc/driver.so if anything is listed as "not found".

hurzhurz avatar Feb 29 '24 11:02 hurzhurz