ModuleNotFoundError No module named mysql

0 votes

Hi Guys,

I am trying to connect MySQL with python. But I am getting this below error.

import mysql.connector
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-e4a81bca169b> in <module>
----> 1 import mysql.connector
ModuleNotFoundError: No module named 'mysql'
Jul 15, 2020 in Python by akhtar
• 38,260 points
50,217 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to install mysql-connector to connect Python with MySQL. You can use the below command to install this in your system.

 C:\Users\Nadeem Akhter>pip install mysql-connector-python-rf
Collecting mysql-connector-python-rf
  Downloading mysql-connector-python-rf-2.2.2.tar.gz (11.9 MB)
     |████████████████████████████████| 11.9 MB 111 kB/s
Building wheels for collected packages: mysql-connector-python-rf
  Building wheel for mysql-connector-python-rf (setup.py) ... done
  Created wheel for mysql-connector-python-rf: filename=mysql_connector_python_rf-2.2.2-cp36-cp36m-win_amd64.whl size=249460 sha256=b3b15baa6cbb68935e2c221725ca7133f2714623b26531f2e34f56b0e3d051ee
  Stored in directory: c:\users\nadeem akhter\appdata\local\pip\cache\wheels\51\40\3f\136443b7177ee453aa9d6c8862fc2d1a1ea8ff8ee0999d1971
Successfully built mysql-connector-python-rf
Installing collected packages: mysql-connector-python-rf
Successfully installed mysql-connector-python-rf-2.2.2
Get a further understanding from the Microsoft SQL course
answered Jul 15, 2020 by MD
• 95,460 points
Sir.
I have installed
pip install mysql-connector-python
pip install mysql-connector-python-rf
pip3 install mysql-connector-python
After installing all this I have worked for 3 hours for completing my project then suddenly it show no module found mysql
Please sir help me it's an emergency
I have also uninstalled and reinstalled it then also I'm getting same
Hi@priyanshu,
After installing the module, restart your command line or your IDE. So that the changes will update.

Actually I had the same issue when running the program in Pycharm, then i realize this really dumb thing, there is a setting include-system-site-packages in the pyvenv.cfg file which somehow was defaulting to false but once it is changed and set to true.  Everything worked.  Hope this helps for everyone.

include-system-site-packages = true
version = 3.8.6
Hello, @Markl,

Thanks for contributing to Edureka's community. Do register with Edureka's community and earn techie points to your account and share your knowledge with all the geeks here!!

Related Questions In Python

+1 vote
3 answers
+2 votes
3 answers

ModuleNotFoundError: No module named 'Crypto'

The module you’ve installed is different. To install ...READ MORE

answered Aug 20, 2019 in Python by Raman
80,711 views
0 votes
2 answers

ModuleNotFoundError: No module named 'pythoncom' in pyttsx3

even i faced the same problem ...just ...READ MORE

answered Jun 2, 2020 in Python by anonymous
13,856 views
0 votes
1 answer

ModuleNotFoundError: No module named 'Foundation'

Hi@akhtar, By default Foundation module comes with Anaconda ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,460 points
3,987 views
0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

answered Sep 10, 2018 in Python by Priyaj
• 58,100 points
20,244 views
0 votes
1 answer

Create a database table using python

Hey @Kim, try something like this: import MySQLdb # ...READ MORE

answered Jul 23, 2019 in Python by Barbara
1,243 views
0 votes
1 answer

How to output text from database with line breaks in a django template?

Hello @kartik, Use linebreaks or linebreaksbr filter: {{ text|linebreaks }} Or surround the text ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,880 points
13,418 views
0 votes
1 answer

Error:Python3.4 can't install mysql-python

Hello @kartik, You can resolved this by the ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,880 points
2,097 views
+3 votes
3 answers

ModuleNotFoundError: No module named 'cv2'

Hi@akhtar, This error may occur if you didn't install ...READ MORE

answered Apr 9, 2020 in Python by MD
• 95,460 points
270,501 views
+2 votes
2 answers

ModuleNotFoundError: No module named 'pyttsx3

Hi@akhtar, To avoid this error you have to ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,460 points
28,936 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP