“OSError: mysql_config not found” when trying to “pip install mysqlclient” - Django

前端 未结 2 1364
迷失自我
迷失自我 2020-12-12 02:14

I\'m relatively new to Django, and Web Development in general.

I am trying to

pip install mysqlclient

in my

virtual         


        
相关标签:
2条回答
  • 2020-12-12 02:27

    You should start with cloning the mysqlclient repo:

    git clone https://github.com/PyMySQL/mysqlclient-python
    

    Then you will have to get mysql-connector-c. You can get it by doing:

    brew install mysql-connector-c
    

    Then open /usr/local/bin/mysql_config in a text editor.

    From the Github issue:

    There are lines in mysql_config like following:

    # Create options 
    libs="-L$pkglibdir"
    libs="$libs -l "
    

    It should be:

    #Create options 
    libs="-L$pkglibdir"
    libs="$libs -lmysqlclient -lssl -lcrypto"
    

    Save that file and change back to the directory where you downloaded the repo. Now open site.cfg file. uncomment the line (remove the #)

    #mysql_config = /usr/local/bin/mysql_config
    

    Save that and run:

    python3 setup.py install
    
    0 讨论(0)
  • 2020-12-12 02:40

    the python package "mysqlclient" is depended on C system library to drive mysql connect,if you on ubuntu 16.4, just do as below:

    sudo apt-get install libmysqlclient-dev
    sudo pip install mysqlclient
    
    0 讨论(0)
提交回复
热议问题