我已经安装了
我想在Django上使用MySQL,但在安装mysql连接器之后我尝试在$ pip install mysqlclient
上安装Python的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/
答案 0 :(得分:15)
我也遇到过这个问题,下面是我的步骤:
<强> 1 强> brew install mysql-connector-c
<强> 2 强> pip install mysqlclient
然后遇到这个错误,我已经跟踪了源代码,但解决了这个,然后发生了其他错误。
所以我改变了安装mysqlclient的方法,只需:
1。brew install mysql
2。pip install mysqlclient
这对我有用,没有任何错误发生。
答案 1 :(得分:11)
我需要以下内容来构建/安装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
答案 2 :(得分:3)
对于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
答案 3 :(得分:3)
使用brew安装mysql并将其添加到路径:
$ brew install mysql
$ export PATH=/usr/local/mysql/bin:$PATH
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
$ pip install mysqlclient
答案 4 :(得分:3)
如果您不打算在计算机中安装mysql-client
,请安装mysql
而不是mysql
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”
export CPPFLAGS =“-I / usr / local / opt / openssl / include”
答案 5 :(得分:2)
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
答案 6 :(得分:0)
在使用 dos2unix entrypoint.sh
使用 Homebrew 安装 MySQL 服务器后,今天这对我有用:
brew install mysql