Python - Can't open lib 'libtdsodbc.so' : file not found

心已入冬 提交于 2019-12-23 12:52:38

问题


Any help with this issue is much appreciated.

Goal: Connect Django to MSSQL server using FreeTDS. I'm using a Debian x64 box.

Problem: When trying to make a connection I get the following.

('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'libtdsodbc.so' : file not found (0) (SQLDriverConnect)")

My /etc/odbcinst.ini is configured as followed

[FreeTDS]
Description = FreeTDS
driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

The files do exist and have 777 access for testing.

The connection string is like

cnxn = pyodbc.connect(
        'DRIVER={FreeTDS};SERVER=' + server + ';PORT=1443;DATABASE=' + database + ';UID=' + username + ';PWD=' + password)
    cursor = cnxn.cursor()

My odbcinst -j reads (since adding symlink)

unixODBC 2.3.1
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

回答1:


If anyone else runs into this hurdle, check out this blog post.

https://emacstragic.net/2017/11/06/mssql-odbc-client-on-debian-9-stretch/

Essentially, I had to target a specific libssl version for it to work.

Looking at the installed versions i found:

ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.1 | grep 'not found'
libcrypto.so.1.0.0 => not found
libssl.so.1.0.0 => not found

and manually installing a previous version fixed the issue

wget "http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb"
sudo apt install ./libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb


来源:https://stackoverflow.com/questions/47180843/python-cant-open-lib-libtdsodbc-so-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!