Solved

ImportError: No module named 'pypyodbc' - python 3.5.2

Posted on 2016-08-05
3
1,414 Views
Last Modified: 2016-08-07
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

0
Comment
Question by:sj77
  • 2
3 Comments
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 41745379
is pypyodbc.py in the current directory or in the module search path?
0
 

Author Comment

by:sj77
ID: 41745793
Hi David -

How can I verify this?
0
 

Author Closing Comment

by:sj77
ID: 41746244
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!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question