Ich habe schon installiert
Ich möchte MySQL mit Django verwenden, aber nach der Installation des MySQL-Connectors habe ich versucht, Mysqlclient für Python auf $ pip install mysqlclient
zu installieren, aber ich habe dieses Problem:
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/
Ich habe dieses Problem auch angetroffen; unten ist mein Schritt:
1. brew install mysql-connector-c
2. pip install mysqlclient
und dann auf diesen Fehler gestoßen ist, habe ich den Quellcode nachverfolgt;.
also habe ich die Installation von mysqlclient geändert:
1 .brew install mysql
2 .pip install mysqlclient
das hat für mich funktioniert, es sind keine Fehler aufgetreten.
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
Für Mac: Erstes Herunterladen von Xcode aus dem App Store und MySqlWorkbench von https://dev.mysql.com/downloads/workbench/
Führen Sie die folgenden Befehle im Terminal aus.
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
Installieren Sie mysql mit brew und fügen Sie es dem Pfad hinzu:
$ 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
Installieren Sie mysql-client
anstelle von mysql
, wenn Sie nicht mysql
auf Ihrem Computer verwenden möchten
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient
Ich brauchte Folgendes zum Erstellen/Installieren von 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/"
Dann könnte ich pip wheel mysqlclient
/pip install mysqlclient
erfolgreich sein