mysql_config not found when installing mysqldb python interface

前端 未结 30 1435
暗喜
暗喜 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:23

    For macOS Mojave , additional configuration was required, for compilers to find openssl you may need to set:

    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl/include"
    
    0 讨论(0)
  • 2020-11-22 07:26

    This method is only for those who know that Mysql is installed but still mysql_config can't be find. This happens if python install can't find mysql_config in your system path, which mostly happens if you have done the installation via .dmg Mac Package or installed at some custom path. The easiest and documented way by MySqlDB is to change the site.cfg. Find the mysql_config which is probably in /usr/local/mysql/bin/ and change the variable namely mysql_config just like below and run the installation again. Don't forget to un-comment it by removing "#"

    Change below line

    "#mysql_config = /usr/local/bin/mysql_config"

    to

    "mysql_config = /usr/local/mysql/bin/mysql_config"

    depending upon the path in your system.

    By the way I used python install after changing the site.cfg

    sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py install

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

    So far, all solutions (Linux) require sudo or root rights to install . Here is a solution if you do not have root rights and without sudo. (no sudo apt install ...):

    1. Download the .deb file of the libmysqlclient-dev, e.g. from this mirror
    2. Navigate to the downloaded file and run dpkg -x libmysqlclient-dev_<version tag>.deb . This will extract a folder called usr.
    3. Symlink ./usr/bin/mysql_config to somewhere that is found on your $PATH:

      ln -s `pwd` /usr/bin/mysql_config FOLDER_IN_YOUR_PATH

    4. It should now be able to find mysql_config

    Tested on Ubuntu 18.04.

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

    mySQLdb is a python interface for mysql, but it is not mysql itself. And apparently mySQLdb needs the command 'mysql_config', so you need to install that first.

    Can you confirm that you did or did not install mysql itself, by running "mysql" from the shell? That should give you a response other than "mysql: command not found".

    Which linux distribution are you using? Mysql is pre-packaged for most linux distributions. For example, for debian / ubuntu, installing mysql is as easy as

    sudo apt-get install mysql-server
    

    mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):

    sudo apt-get install libmysqlclient-dev
    

    if you are using mariadb, the drop in replacement for mysql, then run

    sudo apt-get install libmariadbclient-dev
    

    Reference: https://github.com/JudgeGirl/Judge-sender/issues/4#issuecomment-186542797

    0 讨论(0)
  • On python 3.5.2

    sudo apt-get install libmysqlclient-dev python-dev

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

    sudo apt-get build-dep python-mysqldb will install all the dependencies to build the package from PIP/easy_install

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