Анд*_*нко 13 python mysql django macos
我已经安装好了
我想用Django使用MySQL,但是在安装mysql连接器后我试着安装mysqlclient for Python $ 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/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/
Run Code Online (Sandbox Code Playgroud)
Ant*_*ile 29
我需要以下内容来构建/安装 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/"
Run Code Online (Sandbox Code Playgroud)
然后我可以pip wheel mysqlclient/ pip install mysqlclient成功
小智 17
我也遇到过这个问题,下面是我的步骤:
1.brew install mysql-connector-c
2.pip install mysqlclient
然后遇到这个错误,我已经跟踪了源代码,但解决了这个,然后发生了其他错误.
所以我改变了安装mysqlclient的方法,只需:
1.brew install mysql
2.pip install mysqlclient
这对我有用,没有任何错误发生.
对于 Mac:首先从 App Store 下载 Xcode,从https://dev.mysql.com/downloads/workbench/下载 MySqlWorkbench
在终端中运行以下命令,
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
Run Code Online (Sandbox Code Playgroud)
如果不想将其安装在计算机中,请安装mysql-client而不是安装mysqlmysql
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”
导出CPPFLAGS =“-I / usr / local / opt / openssl / include”
小智 5
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
works perfectly
Run Code Online (Sandbox Code Playgroud)