5

I am getting below error after importing pymysql in jupyter notebook. Please help me to find error.

import pymysql
print("Welcome")

ModuleNotFoundError  
 <ipython-input-5-7978bc79cc40> in <module>()
  1 import pymysql
  2 print("Here")

 ModuleNotFoundError: No module named 'pymysql'
phd
  • 82,685
  • 13
  • 120
  • 165
Sourav_Bharadwaj
  • 175
  • 3
  • 11

3 Answers3

8

You have not installed the module pymysql Try :

python -m pip install pymysql

Or

python3 -m pip install pymysql

for python3.

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
2

It appears that pymsql is not installed in your python environment you are working on.

Please type below command in a cell in jupyter notebook, then run the cell.

 !pip install pymysql

This should resolve your problem.

YoungSheldon
  • 774
  • 6
  • 19
  • I have already installed pymysql. C:\Users\Saurav Bharadwaj>pip3 list Package Version ---------------------- ------- cursor 1.3.4 mysql-connector-python 8.0.21 mysqlclient 2.0.1 numpy 1.19.0 pandas 1.0.5 pip 20.1.1 PyMySQL 0.10.0 pyodbc 4.0.30 python-dateutil 2.8.1 pytz 2020.1 SQLAlchemy 1.3.18 xlrd 1.2.0 – Sourav_Bharadwaj Jul 18 '20 at 12:42
  • Maybe it is installed in different venv, try installing again via the same jupyter notebook. – YoungSheldon Jul 18 '20 at 13:33
0

The reason why despite installation of the pymysql in your system, the issue ModuleNotFoundError: No module named 'pymysql' occurs is because Anaconda does not recognize this.

Another solution to overcome this issue is to install pymysql in the Anaconda prompt.

Issue: ModuleNotFoundError: No module named 'pymysql'

Solution: Installing pymysql in Anaconda Shell

Thank you, Narasimha Rao