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

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

    sometimes the error depends on the actual cause. we had a case where mysql-python was installed through the python-mysqldb debian package.

    a developer who didn't know this, accidentally ran pip uninstall mysql-python and then failed to recover with pip install mysql-python giving the above error.

    pip uninstall mysql-python had destroyed the debian package contents, and of course pip install mysql-python failed because the debian package didn't need any dev files.

    the correct solution in that case was apt-get install --reinstall python-mysqldb which restored mysql-python to its original state.

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

    on MacOS Mojave, mysql_config is found at /usr/local/bin/ rather than /usr/local/mysql/bin as pointed above, so no need to add anything to path.

    0 讨论(0)
  • apt-get install libmysqlclient-dev python-dev
    

    Seemed to do the trick.

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

    You should install the mysql first:

    yum install python-devel mysql-community-devel -y
    

    Then you can install mysqlclient:

    pip install  mysqlclient
    
    0 讨论(0)
  • 2020-11-22 16:12

    You can use the MySQL Connector/Python

    Installation via PyPip

    pip install mysql-connector-python
    

    Further information can be found on the MySQL Connector/Python 1.0.5 beta announcement blog.

    On Launchpad there's a good example of how to add-, edit- or remove data with the library.

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

    OSX Mavericks

    Due to changes within osx mavericks & xcode development tools you may get the error on installation

    clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
    

    therefore use :

    sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mysql-python
    
    0 讨论(0)
提交回复
热议问题