How to install PYODBC in Databricks

后端 未结 3 1397
别跟我提以往
别跟我提以往 2020-12-12 06:25

I have to install pyodbc module in Databricks. I have tried using this command (pip install pyodbc) but it is failed due to below error.

Error message

3条回答
  •  孤城傲影
    2020-12-12 07:03

    I was having the same issue for installation. This is what I tried and it worked.

    • Databricks does not have default ODBC Driver. Run following commands in a single cell to install MS SQL ODBC driver
    %sh
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
    curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
    sudo apt-get update
    sudo ACCEPT_EULA=Y apt-get -q -y install msodbcsql17
    
    • Run this in notebook
    dbutils.fs.put("/databricks/init//pyodbc-install.sh","""
    #!/bin/bash
    sudo apt-get update
    sudo apt-get -q -y install unixodbc unixodbc-dev
    sudo apt-get -q -y install python3-dev
    /databricks/python/bin/pip install pyodbc
    """, True)
    
    • Restart the cluster

    • Import pyodbc in Code

提交回复
热议问题