I trying to open MS Access Database. I have Python 3.10.10
. After the first time I encountered this issue, I tried a few recommended fixes and keep getting the following error
ModuleNotFoundError: No module named 'pyobdc'.
I see the module pyodbc
in the listing by executing ‘pip list’ in the command prompt and by running a Python script that checks for installed packages both outputs confirm that pyodbc
is installed.
Python script output search for modules installed.py:
== RESTART: C:\Code\GUI in Python\How to check which modules are installed.py ==
['altgraph', 'auto-py-to-exe', 'bottle', 'bottle-websocket', 'cffi', 'Eel', 'future', 'gevent', 'gevent-websocket', 'greenlet', 'pefile', 'pycparser', 'pyinstaller', 'pyinstaller-hooks-contrib', 'pyodbc', 'pyparsing', 'pywin32-ctypes', 'whichcraft', 'zope.event', 'zope.interface']
CMD output:
C:\Users\georg>pip list
pyodbc 4.0.35
But when I try to connect to my Access Database I am getting that error.
Which directory does the pyodbc needs to be located in?
I uninstalled pyodbc
and all versions of Python (I had 3.7, 3.8) and reinstalled Python 3.10.10, and using pip installed pyodbc
. Ran the connecting script and still receiveing same error.
I am new to this. I want to start all over. This time I will follow your advice and provide feedback. One thing I found is that MS Access *.accdb
has to be the same bit as Python.
(From mkleehammer)."Therefore, if you already have Microsoft Office it is highly recommended that you use a Python environment that matches the "bitness" of the Office install. https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-Microsoft-Access."
Now I have both at 32-bit. The following was written in 32 bit Python:
import pyodbc
#Making the connection
conn = pyodbc.connect (r' Driver = {Microsoft Access Driver(*mdb, *.accdb)}
DBQ = "C:\Code\GUI in Python\Church membership database development\Test 1 for importing to Python.accdb" ')
Traceback:
============================ RESTART: C:/Code/aa.py ===================
Traceback (most recent call last):
File "C:/Code/aa.py", line 3, in <module>
conn = pyodbc.connect (r' Driver = {Microsoft Access Driver(*mdb, *.accdb)}; DBQ = "C:\Code\GUI in Python\Church membership database development\Test 1 for importing to Python.accdb" ')
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Debug: KeyError: 'pyodbc'