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,230 points
49,250 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
answered Jul 15, 2020 by MD
• 95,440 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
76,823 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
12,872 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,440 points
3,547 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,090 points
19,623 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,072 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
12,661 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
1,809 views
+2 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,440 points
265,165 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,440 points
27,312 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