I had the same error and pip install MySQL-python
solved it for me.
Alternate installs:
easy_install MySQL-python
should work.sudo apt-get install ...
)Below, Soli notes that if you receive the following error:
EnvironmentError: mysql_config not found
... then you have a further system dependency issue. Solving this will vary from system to system, but for Debian-derived systems:
sudo apt-get install python-mysqldb
Running Ubuntu, I had to do:
sudo apt-get install python-mysqldb
Adding to other answers, the following helped me finish the installation mysql-python:
virtualenv, mysql-python, pip: anyone know how?
On Ubuntu...
apt-get install libmysqlclient-dev
apt-get install python-dev
pip install mysql-python
Don't forget to add 'sudo' to the beginning of commands if you don't have the proper permissions.
Try this the commands below. They work for me:
brew install mysql-connector-c
pip install MySQL-python
mysql_config
must be on the path. On Mac, do
export PATH=$PATH:/usr/local/mysql/bin/
pip install MySQL-python
pip install mysql-python
raised an error:
EnvironmentError: mysql_config not found
sudo apt-get install python-mysqldb
fixed the problem.
How I got it working:
virtualenv -p python3.5 env/test
After sourcing my env:
pip install pymysql
pip install django
Then, I ran the startproject and inside the manage.py, I added this:
+ try:
+ import pymysql
+ pymysql.install_as_MySQLdb()
+ except:
+ pass
Also, updated this inside settings:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'foobar_db',
'USER': 'foobaruser',
'PASSWORD': 'foobarpwd',
}
}
I also have configparser==3.5.0
installed in my virtualenv, not sure if that was required or not...
Hope it helps,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With