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

后端 未结 21 2330
广开言路
广开言路 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:17

    Had a similar issue trying to install on OS X Server 10.6.8. Here's what I had to do. Using:

    MySQL-python 1.2.4b4 (source) MySQL-5.6.19 (binary installer) Python 2.7 (binary installer) NOTE: Installing in virtualenv...

    Unzip source, open 'distribute_setup.py' and edit DEFAULT_VERSION to use the latest version of distribute tools, like so:

    DEFAULT_VERSION = "0.6.49"
    

    Save. Open 'site.cfg' file and uncomment the path to mysql_config so it looks something like (reference your own path to mysql_config):

    # 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/mysql/bin/mysql_config
    

    Now clean, build and make will not fail with the 'mysql_config' not found error. Hope this helps someone else trying to make use of their old xserves :-)

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

    I had the same problem in the Terraform:light container. It is based on Alpine.

    There you have to install mariadb-dev with:

    apk add mariadb-dev
    

    But that one is not enough because also all the other dependencies are missed:

    apk add python2 py2-pip gcc python2-dev musl-dev
    
    0 讨论(0)
  • 2020-11-22 16:19

    Try sudo apt-get build-dep python-mysqldb

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

    There maybe various answers for the above issue, below is a aggregated solution.

    For Ubuntu:

    $ sudo apt update
    $ sudo apt install python-dev
    $ sudo apt install python-MySQLdb
    

    For CentOS:

    $ yum install python-devel mysql-devel
    
    0 讨论(0)
  • 2020-11-22 16:22

    In Mac OS, I simply ran this in terminal to fix:

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

    This is the quickest fix I found - it adds it to the path, but I think you're better off adding it permanently (ie add it to /etc/paths) if you plan to install MySQL-python in another environment.

    (tested in OSX Mountain Lion)

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

    if you install MySQL-python in your virtual env, you should check the pip version, if the version is older than 9.0.1, please update it

    pip install --upgrade pip
    
    0 讨论(0)
提交回复
热议问题