Install mysqlclient for Django Python on Mac OS X Sierra

前端 未结 6 2216
小蘑菇
小蘑菇 2020-12-02 23:55

I have already installed

  • Python 2.7.13
  • Django 1.11
  • MySQL 5.7.17

I want use MySQL with Django, but after install mysql connect

相关标签:
6条回答
  • 2020-12-03 00:03

    Install mysql using brew and add it to the path:

    $ brew install mysql
    
    $ export PATH=/usr/local/mysql/bin:$PATH
    
    $ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
    
    $ pip install mysqlclient
    
    0 讨论(0)
  • 2020-12-03 00:05

    I have encountered this problem too,below is my step:

    1.brew install mysql-connector-c

    2.pip install mysqlclient

    and then encountered this error,i have Traced the source code,but solved this one then the other error occured.

    so i changed the way to install mysqlclient,just :

    1.brew install mysql

    2.pip install mysqlclient

    this worked for me,no any errors occured.

    0 讨论(0)
  • 2020-12-03 00:08

    Install mysql-client instead of mysql if you don't plan to have mysql in your computer

    brew install mysql-client

    echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile

    source ~/.bash_profile

    pip install mysqlclient

    export LDFLAGS="-L/usr/local/opt/openssl/lib"

    export CPPFLAGS="-I/usr/local/opt/openssl/include"

    0 讨论(0)
  • 2020-12-03 00:19

    For Mac: first download Xcode from App Store and MySqlWorkbench from https://dev.mysql.com/downloads/workbench/

    Run the following commands in terminal,

    $ brew install mysql
    
    $ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
    
    $ xcode-select --install
    
    $ pip install mysqlclient
    
    0 讨论(0)
  • 2020-12-03 00:20

    I needed the following to build / install mysqlclient

    brew install mysql-client
    # mysql-client is not on the `PATH` by default
    export PATH="/usr/local/opt/mysql-client/bin:$PATH"
    # openssl is not on the link path by default
    export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
    

    Then I could pip wheel mysqlclient / pip install mysqlclient successfully

    0 讨论(0)
  • 2020-12-03 00:23
    brew install/upgrade/reinstall mysql
    brew install mysql-client
    export PATH="/usr/local/opt/openssl/bin:$PATH"
    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl/include"
    pip install mysqlclient
    works perfectly
    
    0 讨论(0)
提交回复
热议问题