mysql_config not found when installing mysqldb python interface

前端 未结 30 1433
暗喜
暗喜 2020-11-22 06:56

I am trying to get a Python script to run on the linux server I\'m connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to i

相关标签:
30条回答
  • 2020-11-22 07:40

    I encountered the same problem, just added the path where *mysql_config* resided to the environment variable PATH and it worked for me.

    0 讨论(0)
  • 2020-11-22 07:42

    (Specific to Mac OS X)

    I have tried a lot of things, but these set of commands finally worked for me.

    1. Install mysql
      brew install mysql
      
    2. brew unlink mysql
    3. brew install mysql-connector-c
    4. Add the mysql bin folder to PATH
      export PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
      
    5. mkdir /usr/local/Cellar/lib/
    6. Create a symlink
      sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
      
    7. brew reinstall openssl (source)
    8. Finally, install mysql-client
      LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysqlclient
      

    Update: In case this doesn't work, @vinyll suggests to run brew link mysql before step 8.

    0 讨论(0)
  • 2020-11-22 07:42

    I got the same error while trying to install mysql-python.

    This is how I fixed it.

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

    The problem was that the installer could not find the mysql_config in the default path. Now it can ..and it worked..

     15 warnings generated.
        clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64
    
    Successfully installed mysql-python
    Cleaning up...
    

    Hope this helps.

    Thanks.

    0 讨论(0)
  • 2020-11-22 07:43

    As actual error is

    gcc ... -I/usr/include/python2.7 ...
    
    _mysql.c:29:20: error: Python.h: No such file or directory
    

    and If you can't install python-dev or python-devel packages, you may download archive with needed version of python sources from http://hg.python.org/ and place headers files in proper folder for include

    0 讨论(0)
  • 2020-11-22 07:44

    In centos 7 this works for me :

    yum install mariadb-devel
    pip install mysqlclient
    
    0 讨论(0)
  • 2020-11-22 07:45

    On Red Hat I had to do

    sudo yum install mysql-devel gcc gcc-devel python-devel
    sudo easy_install mysql-python
    

    Then it worked.

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