pip install mysql-python fails with EnvironmentError: mysql_config not found

后端 未结 21 2328
广开言路
广开言路 2020-11-22 15:58

This is the error I get

(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
  Do         


        
相关标签:
21条回答
  • 2020-11-22 16:03

    For centos users:

    yum install -y mysql-devel python-devel python-setuptools

    then

    pip install MySQL-python


    If this solution doesn't work, and print gcc compile error like:
    _mysql.c:29:20: error: Python.h: No such file or directory

    You need to specify the path of Python.h, like this:
    pip install --global-option=build_ext --global-option="-I/usr/include/python2.6" MySQL-python

    0 讨论(0)
  • 2020-11-22 16:03

    I was trying to install mysql-python on an Amazon EC2 Linux instance and I had to install these :

    yum install mysql mysql-devel mysql-common mysql-libs gcc
    

    But then I got this error :

    _mysql.c:29:20: fatal error: Python.h: No such file or directory
    

    So I installed :

    yum install python-devel
    

    And that did the trick.

    0 讨论(0)
  • 2020-11-22 16:05

    for mariadb install libmariadbclient-dev instead of libmysqlclient-dev

    sudo apt-get install libmariadbclient-dev
    
    0 讨论(0)
  • Your sudo path does not know about your local path... go into superuser mode, add the path, and install it from there.

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

    And you're up and running on OSX. Now you have an updated global python.

    0 讨论(0)
  • 2020-11-22 16:09

    It seems mysql_config is missing on your system or the installer could not find it. Be sure mysql_config is really installed.

    For example on Debian/Ubuntu you must install the package:

    sudo apt-get install libmysqlclient-dev
    

    Maybe the mysql_config is not in your path, it will be the case when you compile by yourself the mysql suite.

    Update: For recent versions of debian/ubuntu (as of 2018) it is

    sudo apt install default-libmysqlclient-dev
    
    0 讨论(0)
  • 2020-11-22 16:09

    If you are on MAC Install this globally

    brew install mysql
    

    then export path like this

    export PATH=$PATH:/usr/local/mysql/bin
    

    Than globally or in your venv whatever you like

    pip install MySQL-Python
    

    Note: globally for python3 as Mac can have both python2 & 3

    pip3 install MySQL-Python
    
    0 讨论(0)
提交回复
热议问题