我正在尝试使用我的django应用程序设置mysql服务器,但是我无法正确安装它。
我使用brew install mysql
安装mysql服务器。
然后我使用pip install mysqlclient
来表示此错误:
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/r9/n0ld0jk57x590rzq5kv8x4wc0000gn/T/pip-build-ZZb7dn/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/r9/n0ld0jk57x590rzq5kv8x4wc0000gn/T/pip-build-ZZb7dn/mysqlclient/
还尝试了pip install MySQL-python
,但它也提供了相同的错误消息。
我在这里做错了吗?请指导我正确的方向,我最近从linux转移到mac os,我对这里的工作方式有点困惑。
注意:我试图在virtual environment
。
答案 0 :(得分:3)
对于Mac上的python3 + django 1.11 + mysql。这对我有用:
brew install mysql-connector-c
which mysql_config
)在mysql_config中更改以下内容:
# Create options #
libs="-L$pkglibdir"
libs="$libs -l "
要:
# Create options #
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl
最后pip3 install mysqlclient
并完成。