Home  >  Article  >  Database  >  Why Can\'t I Install MySQL-python on Ubuntu?: Tracing the \'mysql_config not found\' Error

Why Can\'t I Install MySQL-python on Ubuntu?: Tracing the \'mysql_config not found\' Error

Patricia Arquette
Patricia ArquetteOriginal
2024-11-02 05:35:02666browse

Why Can't I Install MySQL-python on Ubuntu?: Tracing the

Troubleshooting MySQL-python Installation on Ubuntu

While attempting to install MySQL-python on an Ubuntu/Linux machine, you encountered an error indicating that 'mysql_config' was not found. This query explores the root of this issue and provides practical solutions.

Problem

You encountered the following error when trying to install MySQL-python via pip:

Traceback (most recent call last):
  File "<string>", line 14, in <module>
  [...]
  File "setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

Solution

Using Ubuntu's Package Manager (Recommended)

The recommended method for installing MySQL-python on Ubuntu is to use the distribution repository:

sudo apt-get install python-mysqldb

Using pip (Not Recommended)

If you prefer to install using pip, which is not the suggested approach, follow these steps:

  1. Install prerequisites:

    sudo apt-get install build-essential python-dev libmysqlclient-dev
  2. Check the installation guide provided by the developer:
    http://mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to-install.html

The above is the detailed content of Why Can\'t I Install MySQL-python on Ubuntu?: Tracing the \'mysql_config not found\' Error. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn