'Installing pyodbc seems to work, but python cannot find the
I was able to install pyodbc just fine it seems:
pip install pyodbc-4.0.32-cp310-cp310-win_amd64.whl
Processing c:\users\name\appdata\local\programs\python\python310\scripts\pyodbc-4.0.32-cp310-cp310-win_amd64.whl
Installing collected packages: pyodbc
Successfully installed pyodbc-4.0.32
But when I run the code, it fails with the generic error
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Here's the code:
import pyodbc
print("Drivers")
print (pyodbc.drivers())
print ("Sources")
sources = pyodbc.dataSources()
keys = sources.keys()
for key in keys:
print (key)
conn_str = (r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
r'DBQ=C:\pyfun\TradingHubOutput.accdb;')
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()
Here's the output:
Drivers
['SQL Server']
Sources
Traceback (most recent call last):
File "C:\pyfun\playing with DB.py", line 14, in <module>
conn = pyodbc.connect(conn_str)
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
So only one driver. No data sources listed. pyodbc installed ok - rerunning the command gives a confirmation it is install and only prompts for a forced reinstall.
What's going on?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
