Reputation: 6940
I tried conda install -c anaconda mysql-connector-python
from here but after installing it I tried to run import MySQLdb as db
buy it give me error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-08dd46cbf704> in <module>
1 ## package used to connect the database
----> 2 import MySQLdb as db
3 import pandas as pd
4 import numpy as np
5 import warnings
ModuleNotFoundError: No module named 'MySQLdb'
How I can install MySQLdb for Anaconda?
Upvotes: 1
Views: 9983
Reputation: 46284
For MySQLdb
, you have to install mysql-python
for Python 2:
conda install -c anaconda mysql-python
mysqlclient
is the recommended library to use moving forward for Python 2 and 3:
conda install -c anaconda mysqlclient
Here's what Django recommends for mysql libraries https://docs.djangoproject.com/en/3.0/ref/databases/#mysql-db-api-drivers
Upvotes: 6
Reputation: 34285
As per mysqldb's pypi page, you need to install mysqldb as
pip install MySQL-python
In summary: you installed the wrong python library and the correct way is:
conda install -c anaconda mysql-python
Upvotes: 0