从Windows WSL使用PYODBC

时间:2019-01-18 11:26:50

标签: python pyodbc windows-subsystem-for-linux

我正在使用Windows WSL,并且正在尝试配置python以连接到MSSQL

我已经安装了https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-1-configure-development-environment-for-pyodbc-python-development

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server

但是当我按照https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc运行示例连接时,出现此错误:

Traceback (most recent call last):
  File "users.py", line 9, in <module>
    cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
pyodbc.Error: ('01000', u"[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1' : file not found (0) (SQLDriverConnect)")

文件存在:

 khinester@win  /c/Users/norman/Projects/sysadmin   master ? ↑1 ⍟2  ls /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1                                          ✔  5619  15:52:53
-rwxr-xr-x 1 root root 18M Jul  3  2018 /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1

任何有关如何解决此问题的建议都将受到赞赏

0 个答案:

没有答案