Я пытался установить Python-MySQLdb на Mac, и я получаю сообщение об ошибке. Я пробовал так много альтернатив, чтобы пройти эту ошибку.
sudo PATH=/usr/local/Cellar/mysql/bin/:$PATH pip install mysql-python
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
The directory '/Users/zuhairhallak/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo -H flag.
The directory '/Users/zuhairhallak/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo -H flag.
Collecting mysql-python
Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 2.6MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-RtF2js/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, 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/tmp/pip-install-RtF2js/mysql-python/
Я также запустил sudo -H pip install mysql-python и получил другую ошибку
13 предупреждений. cc -bundle -u ndefined dynamic_lookup -Wl, - F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.15/lib -L mysqlclient -L ssl -L crypto -o build/lib. macosx-10.14-intel-2.7/_mysql.so ld: библиотека не найдена для -L ssl clang: ошибка: сбой команды компоновщика с кодом выхода 1 (используйте -v для просмотра вызова) ошибка: сбой команды "cc" при выходе статус 1
Не удалось собрать колесо для mysql-python. Запуск setup.py clean для mysql-python. Не удалось собрать mysql-python. Установка собранных пакетов: mysql-python. Запуск setup.py install для mysql-python... Ошибка. Полный вывод команды /usr/bin./python -u -c "импортировать setuptools, tokenize; file= '/private/tmp/pip-install-3A8kOd/mysql-python/setup.py'; f = getattr (tokenize, 'open', open) (файл); code = f.read(). replace ('\ r\n', '\n'); f.close(); exec (compile (code, file, 'exec')) "install --record/private/tmp/pip-record-TUb4up/install-record.txt --single -v с внешним управлением --compile
Я пошел к файлу mysql_config и открыл его
vi mysql_config
Это было правильно.
Create options:
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"
запустил эту команду в терминале 1. export LDFLAGS = "-L/usr/local/opt/openssl/lib" 2. export CPPFLAGS = "-I/usr/local/opt/openssl/include" 3. pip install mysql -python
Пожалуйста, попробуй
brew install mysql
sudo -H pip install mysql-python