Link to home
Start Free TrialLog in
Avatar of Isaiah Melendez
Isaiah Melendez

asked on

ImportError: No module named 'pypyodbc' - python 3.5.2

Hello Experts -

I am writing a python script to connect to a MSAccess database file and I keep getting an annoying error. Based on google search I found you need to install pypyodbc (which I did) and also call the import of the module. However, but, I still get an error.

I have provided the code and the error below:

import pypyodbc as pyodbc


DBSource = 'C:\\Users\\Database\\Desktop\\GA005_test.mdb'
conn = pypyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\Database\\Desktop\\GA005_test.mdb;")
cursor = conn.cursor()

DBDest = 'C:\\Users\\Database\\Desktop\\ROWBlank.mdb'
conn2 = pypyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\Database\\Desktop\\ROWBlank.mdb;")
cursor2 = conn2.cursor()

SQL = """select *
FROM HRO;"""
for row in cursor.execute(SQL):
    k = row.naam
    print (k)
    cursor2.execute("""insert into ROWBlank.mdb values (?)""", (k))
    conn2.commit()

cursor.close()
conn.close()
cursor2.close()
conn2.close()  

Open in new window


Error:

Traceback (most recent call last):
  File "C:\Users\Database\Desktop\importoldtonew.py", line 1, in <module>
    import pypyodbc as pyodbc
ImportError: No module named 'pypyodbc'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaiah Melendez
Isaiah Melendez

ASKER

Hi David -

How can I verify this?
Thanks for the pointer David. I researched this and found that I had to put it in the dir for python programs.

I clicked on File on IDLE and clicked open module. From there I typed one that I knew would come up "OS" and it should me the raw py file location: C:\Users\Database\AppData\Local\Programs\Python\Python35-32\Lib.

I popped in the pypyodbc.py file in there and it worked. Thanks!