Unable to install pyodbc on Linux

前端 未结 18 1976
野趣味
野趣味 2020-11-28 05:23

I am running Linux (2.6.18-164.15.1.el5.centos.plus) and trying to install pyodbc. I am doing pip install pyodbc and get a very long list of errors, which end in

相关标签:
18条回答
  • 2020-11-28 05:46

    I had the same problem on CentOS 5.5

    In addition to installing unixODBC-devel I also had to install gcc-c++

    yum install gcc-c++
    
    0 讨论(0)
  • 2020-11-28 05:46

    I used this:

    yum install unixODBC.x86_64
    

    Depending on the version of centos could change the package, you can search like this:

    yum search unixodbc
    
    0 讨论(0)
  • 2020-11-28 05:48

    I know this is an old question, but the maintainer has a pyodbc GitHub Repo.

    I also found a very good example for installing FreeTDS and setting up the config files.


    Following the instructions on the GitHub docs seems to me to always be the best option. As of February, 2018, for CentOs7 (they have all flavors at the link) they say:

    # Add the RHEL 6 library for Centos-7 of MSSQL driver. Centos7 uses RHEL-6 Libraries.
    sudo su 
    curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
    exit
    
    # Uninstall if already installed Unix ODBC driver
    sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
    
    # Install the  msodbcsql unixODBC-utf16 unixODBC-utf16-devel driver
    sudo ACCEPT_EULA=Y yum install msodbcsql
    
    #optional: for bcp and sqlcmd
    sudo ACCEPT_EULA=Y yum install mssql-tools
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
    source ~/.bashrc
    
    # optional: for unixODBC development headers
    sudo yum install unixODBC-devel
    
    # the Microsoft driver expects unixODBC to be here /usr/lib64/libodbc.so.1, so add soft links to the '.so.2' files
    cd /usr/lib64
    sudo ln -s libodbccr.so.2   libodbccr.so.1
    sudo ln -s libodbcinst.so.2 libodbcinst.so.1
    sudo ln -s libodbc.so.2     libodbc.so.1
    
    # Set the path for unixODBC
    export ODBCINI=/usr/local/etc/odbc.ini
    export ODBCSYSINI=/usr/local/etc
    source ~/.bashrc
    
    # Prepare a temp file for defining the DSN to your database server
    vi /home/user/odbcadd.txt
    
    [MyMSSQLServer]
    Driver      = ODBC Driver 13 for SQL Server
    Description = My MS SQL Server
    Trace       = No
    Server      = 10.100.1.10
    
    # register the SQL Server database DSN information in /etc/odbc.ini
    sudo odbcinst -i -s -f /home/user/odbcadd.txt -l
    
    # check the DSN installation with:
    odbcinst -j
    cat /etc/odbc.ini
    
    # should contain a section called [MyMSSQLServer]
    
    # install the python driver for database connection
    pip install pyodbc
    
    0 讨论(0)
  • 2020-11-28 05:49

    These 2 commands from here worked for me in RHEL 8

    sudo dnf install redhat-rpm-config gcc-c++ python3-devel unixODBC-devel
    pip3 install --user pyodbc
    
    0 讨论(0)
  • 2020-11-28 05:54

    On Ubuntu, you'll need to install unixodbc-dev:

    sudo apt-get install unixodbc-dev
    

    Install pip by using this command:

    sudo apt-get install python-pip
    

    once that is installed, you should be able to install pyodbc successfully:

    pip install pyodbc
    
    0 讨论(0)
  • 2020-11-28 05:55

    Execute the following commands (tested on centos 6.5):

    yum install install unixodbc-dev
    yum install gcc-c++
    yum install python-devel
    pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
    
    0 讨论(0)
提交回复
热议问题