PyODBC : can't open the driver even if it exists

后端 未结 7 1090
一向
一向 2020-12-31 01:03

I\'m new to the linux world and I want to query a Microsoft SQL Server from Python. I used it on Windows and it was perfectly fine but in Linux it\'s quite painful.

7条回答
  •  一生所求
    2020-12-31 01:37

    I also had the same problem on Ubuntu 14 after following the microsoft tutorial for SQL Server Linux ODBC Driver.

    The file exists and after running an ldd, it showed there were dependencies missing:

    /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.20' not found (required by /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0) /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: versionCXXABI_1.3.8' not found (required by

    after searching for a while I found its because Ubuntu's repo didnt have GLIBCXX on version 3.4.20, it was at 3.4.19.

    I then added a repo to Ubuntu, updated it and forced it to upgrade libstdc++6

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install libstdc++6
    

    Problem solved, tested with isql:

    +---------------------------------------+
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    +---------------------------------------+
    SQL> 
    

    After that I tried testing using pdo_odbc (PHP), it then gave me the same driver not found error. To solve this I had to create a symbolic link to fix libodbcinst.so.2:

    sudo ln -s /usr/lib64/libodbcinst.so.2 /lib/x86_64-linux-gnu/libodbcinst.so.2
    

提交回复
热议问题