Search code examples
pythonmysqlpython-3.xpymysql

Python cannot recognize PyMySQL


I have installed python 3.6.2, Mysql 6.3 and pyMySQL 0.7.11 When running the following scrip

import pymysql
import mysql.connector
class Crud:
def __init__(self):
    self.db = pymysql.connect('localhost', 'dnsmonitor', 'test', 'DNSMON')
    self.cursor = self.db.cursor()

I get the following error

File "demo.py", line 1, in <module>
import pymysql

ModuleNotFoundError: No module named 'pymysql'

What could be the root cause of this issue? I'm running on windows 10


Solution

  • As I posted in the question, I was using Python 3.6.2. Now I downgraded to Python 3.5.3 and that solved the problem.