The Python Oracle

How to use MySQLdb with Python and Django in OSX 10.6?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon

--

Chapters
00:00 Question
01:43 Accepted answer (Score 7)
02:10 Answer 2 (Score 330)
03:08 Answer 3 (Score 62)
03:21 Answer 4 (Score 58)
03:52 Thank you

--

Full question
https://stackoverflow.com/questions/2952...

Question links:
[MySQL for Python]: http://sourceforge.net/projects/mysql-py.../

Accepted answer links:
http://dakrauth.com/blog/entry/python-an.../

Answer 4 links:
[virtualenv, mysql-python, pip: anyone know how?]: https://stackoverflow.com/questions/1511...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #mysql #django #virtualenv #virtualenvwrapper

#avk47



ANSWER 1

Score 329


I had the same error and pip install MySQL-python solved it for me.

Alternate installs:

  • If you don't have pip, easy_install MySQL-python should work.
  • If your python is managed by a packaging system, you might have to use that system (e.g. 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




ANSWER 2

Score 62


Running Ubuntu, I had to do:

sudo apt-get install python-mysqldb



ANSWER 3

Score 58


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.




ANSWER 4

Score 19


mysql_config must be on the path. On Mac, do

export PATH=$PATH:/usr/local/mysql/bin/
pip install MySQL-python