5

So, my apt-get install returns with E: Unable to locate package msodbcsql (error code 100). I'm trying to access an SQL Server database with my system, and so I'm following Microsoft's instructions to install their driver for Linux.

I've tried specifying the package version: apt-get install -y msodbcsql17 and using the package for both Debian 8 and 9. I've tried to confirm the system version, as I'm actually building a Docker container from Debian:stretch-slim -> Python:3.6-slim, and I'm leaning towards Debian 8, because the version number in other images is explicitly 9.

What could be my options trying to install the package? Other ways or steps of troubleshooting?

Many thanks in advance. I'm new to Linux in general, so any pointers are greatly appreciated!

Edit

According to bash: cat /etc/debian_version my version is actually 9.5.

6

I followed the directions on the Microsoft documentation using python:3.6-slim and it appeared to install correctly with a few caveats

You'll need these packages to follow the directions

apt-get update && apt-get install -y curl apt-transport-https gnupg2

The Docker image doesn't have curl, apt-transport-https is required to use Microsoft's repo with https protocol, and gnupg2 is needed for the apt-key command

FROM python:3.6-slim

RUN apt-get update \
        && apt-get install -y curl apt-transport-https gnupg2 \
        && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
        && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
        && apt-get update \
        && ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools

and it looks like this adds an /etc/odbcinst.ini that points at the driver

cat /etc/odbcinst.ini
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1

so you should be able to connect via the "ODBC Driver 17 for SQL Server" ODBC driver

0

This is more like avoiding the problem than actually fixing it, but it works for now. The issue is changing the version requires manual location of the new file, which is not ideal, but perhaps I'll get things working more smoothly some other time.

I found the raw package file using the links provided in the documentation I mentioned in the question. For me the URL was https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/ and the latest package was msodbcsql17_17.2.0.1-1_amd64.deb. Using wget and dpgk I managed to install that package.

The dockerfile commands adding to the usual were:

RUN apt-get install -y curl wget gnupg
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

RUN TEMP_DEB="$(mktemp)" \
 && wget -O "$TEMP_DEB" 'https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/msodbcsql17_17.2.0.1-1_amd64.deb' \
 && yes | dpkg --skip-same-version -i "$TEMP_DEB" \
 && rm -f "$TEMP_DEB"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.