2

so i am trying to get mysql working with django but it requires mysqldb so i downloaded it and then tried to install by unzipping it but this raises an exception

python setup.py build
-----------------------

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/users/tushar/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/users/tushar/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

could you all please help me as am not able to get rid of this exception

Mat
  • 202,337
  • 40
  • 393
  • 406
tushar
  • 307
  • 1
  • 7
  • 17

6 Answers6

2

If your OS is Ubuntu, try "sudo apt-get install python-mysqldb".

Though this might not put your mysqldb into your site-packages, if you prefer to have it there. I usually use this guide to install mysqldb: How to install MySQLdb in a virtualenv on Ubuntu Karmic. This works for virtualenv as well as for normal installation. In the last case simple use pip install MYSQL-python instead of pip install -E default/ MySQL-python.

Torsten Engelbrecht
  • 13,318
  • 4
  • 46
  • 48
1

That should do the trick:

1) sudo apt-get build-dep python-mysqldb

2) pip install MySQL-python

Worked like a charm for me when I have received the same error you have.

Alex Parakhnevich
  • 5,172
  • 4
  • 26
  • 30
1

If your OS is Ubuntu, try "sudo apt-get install python-mysqldb".

Stan
  • 4,169
  • 2
  • 31
  • 39
0

To fix this, do

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

As mentioned in the previous answer, the site.cfg has a hint on what to do - it says to uncomment the path to mysql_config if it is not in your path - so just make sure it is in your path.

I did this and it worked..


15 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64

Successfully installed mysql-python
Cleaning up...

Hope this helps.

Thanks.

Mayank R Jain
  • 3,127
  • 1
  • 29
  • 43
0

Install "-devel" package. What is missing is a development libraries and tools provided by mysql.

Another cause can be that devel-package (especially mysql_config program is not in your path).

Jerzyk
  • 3,662
  • 23
  • 40
0

The problem is that mysql_config is not found. In the site.cfg file (inside MySQL-python-1.2.3) you can see the following:

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
#mysql_config = /usr/local/bin/mysql_config

You need to have mysql server installed for installing the MySQL-python module. If you installed mysql server with the package manager, mysql_config should be in the path. If you have a mysql custom installation, you can either add the mysql bin directory to the path or uncomment the mysql-config line in the site.cfg file pointing to the right location.

kaysa
  • 1,491
  • 13
  • 9