Fresh python 3.7 / django 2.2.1 installation not recognising that mysqlclient is installed

前端 未结 3 398
花落未央
花落未央 2021-01-14 18:39

I have a brand new django 2.2.1 project I have just installed into a python 3.7 virtualenv on OS X (10.14.4). After some frustrations I got mysqlclient to install but when I

相关标签:
3条回答
  • 2021-01-14 18:44

    SOLVED

    So it looks like the issue was that on initial installation the mysqlclient library had compiled against the wrong version of mysql (not sure how that happened), so I had to force it to recompile.

    Here are the steps:

    brew uninstall mysql
    brew uninstall myysql-connector-c
    pipenv uninstall mysqlclient
    brew install mysql-connector-c
    

    At this point we need to update /usr/local/bin/mysql_config as per the instructions that conor linked to (thanks again conor), i.e. change the line that read

    libs="$libs -l "
    

    to

    libs="$libs -lmysqlclient -lssl -lcrypto "
    

    Then, to fix the resultant "library not found for -lssl" error I used the answer from this question:

    export PATH="/usr/local/opt/openssl/bin:$PATH"
    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl/include"
    

    Then finally force mysqlclient to recompile and reinstall mysql:

    pip install --force-reinstall --ignore-installed --no-binary :all: mysqlclient
    brew unlink mysql-connector-c
    brew install mysql
    

    Thanks to everyone who took time to help out!

    0 讨论(0)
  • 2021-01-14 18:45

    If you're on macos do this

    $ brew uninstall mysql
    $ brew install mysql-connector-c
    $ brew unlink mysql-connector-c
    $ brew install mysql
    $ pip install mysql-python
    

    and follow the instructions here: https://pypi.org/project/mysqlclient/

    0 讨论(0)
  • 2021-01-14 19:05

    Downgrading from python 3.7.4 to python 3.6 solved the issue for me on windows 10.

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