title: Cannot connect to Azure SQL Server using pyodbc
body: <p>Yet another post about an Azure SQL Server connection problem from Python I'm afraid.  I've been through multiple threads on this site, Microsoft's site and other links via Google but I cannot get this working.</p>
  
  <p>I'm using the latest version of Anaconda (Python 3.6.6) and have ODBC driver version 17.2.0.1 installed.</p>
  
  <p>Using the following script:</p>
  
  <pre><code>import pyodbc
  
  server = server = 'myserver.database.windows.net,1433' #also tried prepending tcp:....
  database = 'db1' #not the real db name
  username = 'username@myserver' #also tried username@mydomain.com
  password = '123456' #obviously not my real password!
  driver= '{ODBC Driver 17 for SQL Server}' #also tried v13 ODBC driver and 'SQL Server' here
  
  cnxn = pyodbc.connect('DRIVER='+driver+';PORT=1433;SERVER='+server+';DATABASE='+database+';UID='+username)
  
  cursor = cnxn.cursor()
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error: ('IM004', "[IM004] [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed (0) (SQLDriverConnect)")
  </code></pre>
  
  <p>Can anybody offer any insights please?</p>