title: ODBC Driver 13 for SQL Server can't open lib on pyodbc while connecting on AWS E2 ubuntu instance
body: <p><strong>Background:</strong> i have been at it for about a week but still no luck. the same driver (13.0) on my system  (Ubuntu 16.04.1 LTS) works just fine with my pyodbc python (Python 2.7.12 :: Anaconda 4.1.1 (64-bit)) library. i tried setting up a virtual machine on AWS E2 but it does not work there as described below.</p>
  
  <p><strong>Objective:</strong> Connect to Azure SQL Server using <code>Python 2.7.12 :: Anaconda 4.2.0 (64-bit)</code> with official <a href="https://blogs.msdn.microsoft.com/sqlnativeclient/2016/10/20/odbc-driver-13-0-for-linux-released/" rel="nofollow noreferrer">ODBC Driver from Microsoft</a> on Amazon Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)</p>
  
  <p><strong>Problem:</strong> I have tried connecting pyodbc to azure sql using the ODBC official ODBC driver 13 from Microsoft on AWS E2 Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64) image but always ended up with an error:</p>
  
  <p>Using a complete connection string:</p>
  
  <pre><code>$ python
  Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:42:40) 
  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  Anaconda is brought to you by Continuum Analytics.
  Please check out: http://continuum.io/thanks and https://anaconda.org
  &gt;&gt;&gt; import pyodbc
  &gt;&gt;&gt; pyodbc.connect("DRIVER={ODBC Driver 13 for SQL Server};SERVER=myserver;DATABASE=mydatabase;UID=username;PWD=password")
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0' : file not found (0) (SQLDriverConnect)")
  </code></pre>
  
  <p>Using <strong>DSN</strong>:</p>
  
  <pre><code>&gt;&gt;&gt; pyodbc.connect("DSN=MSSQL;UID=username;PWD=password")Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0' : file not found (0) (SQLDriverConnect)")
  </code></pre>
  
  <p><code>pyodbc</code> version:</p>
  
  <pre><code>$ pip list | grep pyodbc
  pyodbc (3.1.1)
  pypyodbc (1.3.3)
  </code></pre>
  
  <p>My <code>odbcinst</code>:</p>
  
  <pre><code>$ odbcinst -j
  unixODBC 2.3.1
  DRIVERS............: /usr/local/etc/odbcinst.ini
  SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
  FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
  USER DATA SOURCES..: /home/ubuntu/.odbc.ini
  SQLULEN Size.......: 8
  SQLLEN Size........: 8
  SQLSETPOSIROW Size.: 8
  </code></pre>
  
  <p><code>odbcinst.ini</code> file:</p>
  
  <pre><code>[ODBC Driver 13 for SQL Server]
  Description=Microsoft ODBC Driver 13 for SQL Server
  Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
  UsageCount=1
  </code></pre>
  
  <p><code>odbc.ini</code> file:</p>
  
  <pre><code>[MSSQL]
  Driver = ODBC Driver 13 for SQL Server
  Description = SQL Server DSN
  Server = myserverlurl
  Database = mydatabasename
  </code></pre>
  
  <p>Ironically, isql connects just fine!!:</p>
  
  <pre><code>$ isql MSSQL &lt;user&gt; &lt;password&gt; -v
  +---------------------------------------+
  | Connected!                            |
  |                                       |
  | sql-statement                         |
  | help [tablename]                      |
  | quit                                  |
  |                                       |
  +---------------------------------------+
  SQL&gt; 
  </code></pre>
  
  <p>ldd result on libmsodbcsql does <strong>NOT</strong> returns any "not found" libraries:</p>
  
  <pre><code>$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
      linux-vdso.so.1 =&gt;  (0x00007ffdabd67000)
      libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbf5cb27000)
      libodbcinst.so.2 =&gt; /usr/local/lib/libodbcinst.so.2 (0x00007fbf5c915000)
      libuuid.so.1 =&gt; /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fbf5c70f000)
      libcurl.so.4 =&gt; /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007fbf5c4a0000)
      libgssapi_krb5.so.2 =&gt; /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fbf5c256000)
      libkrb5.so.3 =&gt; /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fbf5bf83000)
      libcrypto.so.1.0.0 =&gt; /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fbf5bb3f000)
      libssl.so.1.0.0 =&gt; /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fbf5b8d6000)
      libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbf5b54d000)
      libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbf5b244000)
      libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbf5b02d000)
      libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbf5ae0f000)
      libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbf5aa46000)
      /lib64/ld-linux-x86-64.so.2 (0x00005611cb357000)
      libltdl.so.7 =&gt; /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007fbf5a83c000)
      libidn.so.11 =&gt; /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007fbf5a608000)
      librtmp.so.1 =&gt; /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007fbf5a3ec000)
      liblber-2.4.so.2 =&gt; /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007fbf5a1dd000)
      libldap_r-2.4.so.2 =&gt; /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007fbf59f8b000)
      libz.so.1 =&gt; /lib/x86_64-linux-gnu/libz.so.1 (0x00007fbf59d71000)
      libk5crypto.so.3 =&gt; /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fbf59b42000)
      libcom_err.so.2 =&gt; /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fbf5993d000)
      libkrb5support.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fbf59732000)
      libkeyutils.so.1 =&gt; /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fbf5952e000)
      libresolv.so.2 =&gt; /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fbf59312000)
      libgnutls.so.30 =&gt; /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007fbf58fe2000)
      libhogweed.so.4 =&gt; /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007fbf58dae000)
      libnettle.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007fbf58b78000)
      libgmp.so.10 =&gt; /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fbf588f8000)
      libsasl2.so.2 =&gt; /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007fbf586dc000)
      libgssapi.so.3 =&gt; /usr/lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007fbf5849b000)
      libp11-kit.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fbf58236000)
      libtasn1.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fbf58023000)
      libheimntlm.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007fbf57e19000)
      libkrb5.so.26 =&gt; /usr/lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007fbf57b8f000)
      libasn1.so.8 =&gt; /usr/lib/x86_64-linux-gnu/libasn1.so.8 (0x00007fbf578ed000)
      libhcrypto.so.4 =&gt; /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007fbf576ba000)
      libroken.so.18 =&gt; /usr/lib/x86_64-linux-gnu/libroken.so.18 (0x00007fbf574a3000)
      libffi.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fbf5729b000)
      libwind.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libwind.so.0 (0x00007fbf57072000)
      libheimbase.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007fbf56e62000)
      libhx509.so.5 =&gt; /usr/lib/x86_64-linux-gnu/libhx509.so.5 (0x00007fbf56c17000)
      libsqlite3.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007fbf56942000)
      libcrypt.so.1 =&gt; /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fbf56709000)
  </code></pre>
  
  <p>i have tried making symbolic links of libodbcinst.so.2 as suggested by other stackoverflow answers:</p>
  
  <pre><code>$ locate libodbcinst.so.2
  /lib/x86_64-linux-gnu/libodbcinst.so.2
  /lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
  /lib64/libodbcinst.so.2
  /usr/lib/x86_64-linux-gnu/libodbcinst.so.2
  /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
  /usr/local/lib/libodbcinst.so.2
  /usr/local/lib/libodbcinst.so.2.0.0
  </code></pre>