Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install mysqlclient for Django Python on Mac OS X Sierra

Tags:

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 connector I was try to install mysqlclient for Python on $ pip install mysqlclient, but I have this issue:

Collecting mysqlclient   Using cached mysqlclient-1.3.10.tar.gz     Complete output from command python setup.py egg_info:     Traceback (most recent call last):       File "<string>", line 1, in <module>       File "/private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/setup.py", line 17, in <module>         metadata, options = get_config()       File "setup_posix.py", line 54, in get_config         libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]       File "setup_posix.py", line 12, in dequote         if s[0] in "\"'" and s[0] == s[-1]:     IndexError: string index out of range      ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/ 
like image 561
Андрей Морченко Avatar asked Apr 25 '17 13:04

Андрей Морченко


People also ask

Does Django need Mysqlclient?

Django requires mysqlclient 1.4.


1 Answers

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

like image 92
Anthony Sottile Avatar answered Sep 28 '22 10:09

Anthony Sottile