Search code examples
odbcazure-databrickspyodbc

ODBC Driver Installation in Databricks


I am trying to install ODBC driver in azure databricks. But I am facing below error message,

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required

Approaches that I followed to install: Cluster Runtime Version: 13.3 LTS (includes Apache Spark 3.4.1, Scala 2.12)

  1. Installed pyodbc to the cluster itself from pypi.
  2. Used below script to install ODBC driver 17
%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
  1. Received error
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
  1. Then Tried removing sudo. Received error E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

  2. Tried to run it as root user with sudo -s, received error E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

Please let me know how to resolve this issue, as I am struck in this issue for multiple days.


Solution

  • No, you can't do this on the shared clusters, at least not in the interactive mode, because users are isolated from each other. You need to put actual commands (see below) into the init script and attach it to your cluster (see docs for details):

    Code of the init script:

    #!/bin/bash
    
    curl --silent https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
    curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
    # Install msodbcsql17
    apt-get update
    ACCEPT_EULA=Y apt-get --quiet ---yes install msodbcsql17