title: Pyodbc works in non-conda python, but fails to load drivers in conda
body: <p>I have a simple connection string for connection to a MSSQL server running in a local docker container. The code works fine in python 3.7 (not conda), but fails in any conda environment. I'm specifically interested in getting it to work in a Jupyter notebook. </p>
  
  <p>I've recently re-installed Anaconda, but that seems unrelated as it still isn't working. My .bash_profile seems to be a bit of a mess, but I've been reluctant to make changes there before I'm sure about what I'm doing. </p>
  
  <p>As best I can tell, my conda version of python can't find the pyodbc drivers that the other version of python is using. </p>
  
  <p>this code works in any non-conda version of Python for me but fails elsewhere. </p>
  
  <pre><code>import pyodbc
  drivers = [item for item in pyodbc.drivers()]
  driver = drivers[-1]
  print("driver:{}".format(driver))
  server = '192.168.0.4'
  database = 'XXXXXXX'
  uid = 'sa'
  pwd = 'XXXXXXXXXX'
  con_string = f'DRIVER={driver};SERVER={server};PORT=1433;DATABASE={database};UID={uid};PWD={pwd}'
  print(con_string)
  cnxn = pyodbc.connect(con_string)
  
  
  cursor = cnxn.cursor()
  print('connected')
  
  cursor.execute('SELECT * FROM TB_STYLE_AUDIT')
  
  for row in cursor:
      print(row)
  </code></pre>
  
  <p>expected results (shortened):</p>
  
  <pre><code>/usr/local/bin/python3.7 /Users/mycomputer/Documents/Pythonprojects/BuildingOldHistory/getHistoricaldata.py
  driver:ODBC Driver 17 for SQL Server
  DRIVER=ODBC Driver 17 for SQL Server;SERVER=192.168.0.4;PORT=1433;DATABASE=XXXXXXX;UID=sa;PWD=XXXXXXX
  connected
  (37962, 107, 555255, 662895, 689233, datetime.datetime(2016, 6, 8, 13, 22, 38), 1, '', '', '', -1.0, -10.0, -20.0, 'Sale', '1086504', '1088527', None, 18, None)
  </code></pre>
  
  <p>here is the error from conda: </p>
  
  <pre><code>IndexError                                Traceback (most recent call last)
  &lt;ipython-input-1-ea3728340faa&gt; in &lt;module&gt;
        2 
        3 drivers = [item for item in pyodbc.drivers()]
  ----&gt; 4 driver = drivers[-1]
        5 print("driver:{}".format(driver))
        6 server = '192.168.0.4'
  
  IndexError: list index out of range
  </code></pre>
  
  <p>Editing to add that this code also works outside of conda:</p>
  
  <pre><code>import pyodbc
  
  #drivers = [item for item in pyodbc.drivers()]
  #driver = drivers[-1]
  #print("driver:{}".format(driver))
  driver = 'ODBC Driver 17 for SQL Server'
  server = '192.168.0.4'
  database = 'XXXXXXX'
  uid = 'sa'
  pwd = 'XXXXXXX'
  con_string = f'DRIVER={driver};SERVER={server};PORT=1433;DATABASE={database};UID={uid};PWD={pwd}'
  print(con_string)
  cnxn = pyodbc.connect(con_string)
  
  
  cursor = cnxn.cursor()
  print('connected')
  
  cursor.execute('SELECT * FROM TB_STYLE_AUDIT')
  
  for row in cursor:
      print(row)
  </code></pre>
  
  <p>but produces this error in a notebook: </p>
  
  <pre><code>---------------------------------------------------------------------------
  Error                                     Traceback (most recent call last)
  &lt;ipython-input-2-3f7d96055440&gt; in &lt;module&gt;
       11 con_string = f'DRIVER={driver};SERVER={server};PORT=1433;DATABASE={database};UID={uid};PWD={pwd}'
       12 print(con_string)
  ---&gt; 13 cnxn = pyodbc.connect(con_string)
       14 
       15 
  
  Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
  </code></pre>