Solved

ImportError: No module named 'pypyodbc' - python 3.5.2

Posted on 2016-08-05
3
1,113 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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