Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql_config not found when installing mysqldb python interface

I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via setuptools like so:,

python setup.py install 

I get the following error report related to the mysql_config command.

sh: mysql_config: command not found Traceback (most recent call last):   File "setup.py", line 15, in <module>     metadata, options = get_config()   File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config     libs = mysql_config("libs_r")   File "/usr/lib/python2.5/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 

Has anyone else encountered this error and if so how did you resolve it/what can I do to successfully install mysqldb?

like image 743
user904542 Avatar asked Sep 19 '11 18:09

user904542


People also ask

Can not import MySQLdb?

Solution: Fix ImportError: No module named MySQLdb It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Python module and the script should work without any problem.

What is Mysql_config?

1 mysql_config — Display Options for Compiling Clients. mysql_config provides you with useful information for compiling your MySQL client and connecting it to MySQL. It is a shell script, so it is available only on Unix and Unix-like systems.


1 Answers

mySQLdb is a python interface for mysql, but it is not mysql itself. And apparently mySQLdb needs the command 'mysql_config', so you need to install that first.

Can you confirm that you did or did not install mysql itself, by running "mysql" from the shell? That should give you a response other than "mysql: command not found".

Which linux distribution are you using? Mysql is pre-packaged for most linux distributions. For example, for debian / ubuntu, installing mysql is as easy as

sudo apt-get install mysql-server 

mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):

sudo apt-get install libmysqlclient-dev 

if you are using mariadb, the drop in replacement for mysql, then run

sudo apt-get install libmariadbclient-dev 

Reference: https://github.com/JudgeGirl/Judge-sender/issues/4#issuecomment-186542797

like image 91
amarillion Avatar answered Oct 04 '22 11:10

amarillion