在Mac OS X Sierra上为Django Python安装mysqlclient [英] Install mysqlclient for Django Python on Mac OS X Sierra
本文介绍了在Mac OS X Sierra上为Django Python安装mysqlclient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了
- Python 2.7.13
- Django 1.11
- MySQL 5.7.17
我想在Django上使用MySQL,但是在安装mysql连接器后,我尝试在$ pip install mysqlclient
上为Python安装mysqlclient,但是我遇到了这个问题:
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/
推荐答案
我需要以下内容来构建/安装mysqlclient
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/"
然后我可以成功pip wheel mysqlclient
/pip install mysqlclient
这篇关于在Mac OS X Sierra上为Django Python安装mysqlclient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文