“my_config.h” file not found when install mysql-python on osx 10.8

前端 未结 12 1970
礼貌的吻别
礼貌的吻别 2020-12-07 11:06

I face this problem when I want to install mysql-python on osx 10.8, it show error with \'my_config.h\' file not found.

Below is my running code:

sud         


        
相关标签:
12条回答
  • 2020-12-07 11:57

    I tried all the way from answers,that does't work for me.

    1. Just download mysql from https://dev.mysql.com/downloads/mysql/ and install in your mac. do not use brew install mysql

    2. install MySQL-python

      pip install MySQL-python  
      

    every thing done

    0 讨论(0)
  • 2020-12-07 11:57

    Using conda instead of pip solved this for me on macOS Catalina 10.15.5

    conda install mysql-python
    
    0 讨论(0)
  • 2020-12-07 12:00
    brew install mysql
    brew unlink mysql
    brew install mysql-connector-c
    sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config
    pip install MySQL-python
    brew unlink mysql-connector-c
    brew link --overwrite mysql
    
    0 讨论(0)
  • 2020-12-07 12:03

    On macOS 10.15 so long as your project is compatible with PyMySQL 1.3.11 or newer, the following appears to resolve this problem:

    brew install mariadb-connector-c
    pip install MySQL-python
    

    Ref: https://github.com/PyMySQL/mysqlclient-python/blob/master/HISTORY.rst

    0 讨论(0)
  • 2020-12-07 12:04

    My problem was that I was using MAMP's version of mysql and it didn't contain the dev headers. I downloaded the dmg of the official release and had it running in no time.

    0 讨论(0)
  • 2020-12-07 12:06

    I checked the include folders for both mysql and mysql-connector-c installed by homebrew and was surprised to see there is NO file named my_config.h. Thus, I think existing high-voted answers can no longer solve the problem.

    Here is my solution for mysql 8.0.19. I copied the mysql.h file under the include/ folder of my installed mysql-connector-c and saved it as my_config.h under the same folder. Then I followed the high-voted solution as below and successfully installed mysql-python 1.2.5.

    brew install mysql
    brew unlink mysql
    brew install mysql-connector-c   # modify the include/ folder after installing the package
    sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/Cellar/mysql/8.0.19/bin/mysql_config
    pip install MySQL-python
    brew unlink mysql-connector-c
    brew link --overwrite mysql
    

    At present, I only know it can successfully install the package, but I am not sure whether it is a safe solution.

    Actually, mysql-python is a quite old package (the latest release is 6 years ago), I recommend other packages for interacting with mysql in python (e.g. mysql-connector-python).

    0 讨论(0)
提交回复
热议问题