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
208k41 gold badges409 silver badges423 bronze badges
asked Mar 20, 2011 at 16:01
3
  • You do have mysql installed ? Commented Mar 20, 2011 at 16:38
  • 1
    It's basically saying that the command mysql_config can't be found - either because you don't have MySQL installed, or because it's not in your path. What kind of computer are you on - Windows, Mac, Linux? Commented Mar 20, 2011 at 16:51
  • Have you tried the pre-build binary from code.activestate.com/pypm/mysql-python ? Commented Mar 21, 2011 at 19:29

6 Answers 6

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.

answered Mar 21, 2011 at 1:43
Sign up to request clarification or add additional context in comments.

Comments

1

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

answered Mar 20, 2011 at 20:19

1 Comment

Does Python need to be recompiled after that ?
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.

answered Oct 19, 2013 at 16:09

Comments

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).

answered Mar 20, 2011 at 16:46

Comments

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.

answered Aug 29, 2011 at 9:43

Comments

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.

answered Oct 3, 2012 at 11:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.