Install MySQL-python

I got a failure while trying to install MySQL-python on my Ubuntu / Linux Box. From below, it looks like the problem is: sh: mysql_config: not found Can someone advise me what to do?

 rmicro@ubuntu:~$ pip install MySQL-python Downloading/unpacking MySQL-python Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded Running setup.py egg_info for package MySQL-python sh: mysql_config: not found Traceback (most recent call last): File "<string>", line 14, in <module> File "/home/rmicro/build/MySQL-python/setup.py", line 15, in <module> metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found Complete output from command python setup.py egg_info: sh: mysql_config: not found Traceback (most recent call last): File "<string>", line 14, in <module> File "/home/rmicro/build/MySQL-python/setup.py", line 15, in <module> metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found ---------------------------------------- Command python setup.py egg_info failed with error code 1 
+56
python mysql
Sep 18 2018-11-11T00:
source share
7 answers

Ubuntu recommends using the distribution repository. Therefore, the installation of python-mysqldb should be direct:

 sudo apt-get install python-mysqldb 

If you really want to use pip to install, as mentioned earlier, and not the suggested path, but maybe please look at this previously asked question and answer: pip install mysql -python does not work with EnvironmentError: mysql_config not found

Here is a detailed developer guide: http://mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to-install.html

To get all the prerequisites for python-mysqld to install it with pip (which you want to do if using virtualenv), run this:

 sudo apt-get install build-essential python-dev libmysqlclient-dev 
+137
Sep 18 2018-11-18T00:
source share

You have 2 options, as described below:




A distribution package such as Glaslos suggested:

 # sudo apt-get install python-mysqldb 

In this case, you cannot use virtualenv no-site-packages (the default option) but you must use:

 # virtualenv --system-site-packages myenv 



Use pure virtualenv and create your own python-mysql package.

First create virtualenv:

 # virtualenv myvirtualenv # source myvirtualenv/bin/activate 

Then install the build dependencies:

 # sudo apt-get build-dep python-mysqldb 

Now you can install python-mysql

 # pip install mysql-python 



NOTE Ubuntu package is python-mysql * db *, python pypi package is python-mysql (without db )

+11
Jul 17 2018-12-12T00:
source share
 yum install mysql-devel 

It worked for me.

+9
Sep 03 '13 at 9:59 on
source share

Reread the error message. It says:

sh: mysql_config: not found

If you are on Ubuntu Natty, mysql_config belongs to the libmysqlclient-dev package

+7
Sep 18 '11 at 6:44
source share
  • find the folder: sudo find / -name "mysql_config" (suppose that "/opt/local/lib/mysql5/bin" )

  • add it to PATH: export PATH:export PATH=/opt/local/lib/mysql5/bin:$PATH

  • install it again

+1
Dec 05 '11 at 6:30
source share

Python or Python3 with MySQL, you will need these. These libraries use the MySQL connector for C and Python (you also need the C libraries), which remove some of the limitations of the mysqldb libraries.

  sudo apt-get install libmysqlclient-dev sudo apt-get install python-mysql.connector sudo apt-get install python3-mysql.connector 
+1
Mar 23 '16 at 0:28
source share

this worked for me in python 3

pip install mysqlclient

+1
Jun 26 '17 at 14:27
source share



All Articles