0
1

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 3 years have passed since last update.

Macでmysqlclientのpip install時に出るエラー

Posted at

概要

Macで環境作り直してpip install mysqlclientしようとするとたまに出るエラー
いつも対処法を忘れるのでメモ

エラー内容

エラー出力
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/user/develop/api/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z_/62bk1p8s7mj1p5_nq48s81gr0000gp/T/pip-install-8k8ewh_h/mysqlclient_980254ec895e421ba41a7ec66c0ccde2/setup.py'"'"'; __file__='"'"'/private/var/folders/z_/62bk1p8s7mj1p5_nq48s81gr0000gp/T/pip-install-8k8ewh_h/mysqlclient_980254ec895e421ba41a7ec66c0ccde2/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/z_/62bk1p8s7mj1p5_nq48s81gr0000gp/T/pip-record-wtb2wvgb/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/develop/api/venv/include/site/python3.8/mysqlclient
         cwd: /private/var/folders/z_/62bk1p8s7mj1p5_nq48s81gr0000gp/T/pip-install-8k8ewh_h/mysqlclient_980254ec895e421ba41a7ec66c0ccde2/
    Complete output (70 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.8
    copying _mysql_exceptions.py -> build/lib.macosx-10.15-x86_64-3.8
    creating build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb
    creating build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.15-x86_64-3.8/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.15-x86_64-3.8
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Dversion_info=(1,3,14,'final',0) -D__version__=1.3.14 -I/usr/local/opt/mysql@5.7/include/mysql -I/Users/user/develop/api/venv/include -I/Users/user/.pyenv/versions/3.8.0/include/python3.8 -c _mysql.c -o build/temp.macosx-10.15-x86_64-3.8/_mysql.o
    _mysql.c:265:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                            s = PyUnicode_AsUTF8(item);
                              ^ ~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:295:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                            s = PyUnicode_AsUTF8(item);
                              ^ ~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:569:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(ca, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:559:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:570:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(capath, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:559:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:571:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(cert, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:559:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:572:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(key, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:559:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:573:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(cipher, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:559:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:2557:8: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            cname = PyUnicode_AsUTF8(name);
                  ^ ~~~~~~~~~~~~~~~~~~~~~~
    8 warnings generated.
    clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.pyenv/versions/3.8.0/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.pyenv/versions/3.8.0/lib build/temp.macosx-10.15-x86_64-3.8/_mysql.o -L/usr/local/opt/mysql@5.7/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.15-x86_64-3.8/_mysql.cpython-38-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'clang' failed with exit status 1
    ----------------------------------------

対応

環境変数LDFFAGSCPPFLAGSを設定する

コマンド
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install mysqlclient

参考

0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?