3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonでmysqlclientが入らずエラーが出る(なんとか解決はしたが理由は不明)

Posted at

mysqlclientが入らない。以下のエラーが出る

Installing collected packages: mysqlclient, pytz, urllib3, requests, sb-django-redis-sentinel
  Found existing installation: mysqlclient 1.3.13
    Uninstalling mysqlclient-1.3.13:
      Successfully uninstalled mysqlclient-1.3.13
  Running setup.py install for mysqlclient ... error
    Complete output from command /Users/masato-naka/.pyenv/versions/3.6.5/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/kz/98sbqxgj04d2vx6prgf92w_wbx535f/T/pip-install-_6lb1k_w/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/kz/98sbqxgj04d2vx6prgf92w_wbx535f/T/pip-record-e5s33jv8/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.13-x86_64-3.6
    copying _mysql_exceptions.py -> build/lib.macosx-10.13-x86_64-3.6
    creating build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    creating build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.13-x86_64-3.6
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/Cellar/mysql/8.0.11/include/mysql -I/Users/masato-naka/.pyenv/versions/3.6.5/include/python3.6m -c _mysql.c -o build/temp.macosx-10.13-x86_64-3.6/_mysql.o
    _mysql.c:29:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
  Rolling back uninstall of mysqlclient
Command "/Users/masato-naka/.pyenv/versions/3.6.5/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/kz/98sbqxgj04d2vx6prgf92w_wbx535f/T/pip-install-_6lb1k_w/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/kz/98sbqxgj04d2vx6prgf92w_wbx535f/T/pip-record-e5s33jv8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/kz/98sbqxgj04d2vx6prgf92w_wbx535f/T/pip-install-_6lb1k_w/mysqlclient/

とりあえず、https://stackoverflow.com/questions/50940302/installing-mysql-python-causes-command-clang-failed-with-exit-status-1-on-macを参考にやってみる。

brew unlink mysql # only if installed, causes the next step to fail
brew install mysql-connector-c
vim $(which mysql_config)
libs="$libs -l "

を以下のように

libs="$libs -lmysqlclient -lssl -lcrypto"

変更する

pip install mysqlclient
pip install MySQL-python
brew unlink mysql-connector-c
brew link mysql

これでもだめで、最後に、mysql-connector-cをでリンクを上書きしたら・・・

brew link --overwrite mysql-connector-c
Linking /usr/local/Cellar/mysql-connector-c/6.1.11... 73 symlinks created

入った。。。

理由は完全にはわからず。

誰か、知ってたら教えてください。

3
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?