Solved

ImportError: No module named 'pypyodbc' - python 3.5.2

Posted on 2016-08-05
3
420 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 78

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now