afraid.jpg
afraid.jpg

Reputation: 1175

python3.7 pip install mysqlclient failed with 'Building wheel for mysqlclient (setup.py) ... error'

system: MacOS 10.14.3

python: 3.7.3

mysql: 5.7.25 (install by brewhome: brew install [email protected])

when l used pip install myclient, l got an error track back with following:

ERROR: Complete output from command /Users/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-wheel-hom1hl9x --python-tag cp37:
  ERROR: running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-x86_64-3.7
  copying _mysql_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7
  creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
  creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.14-x86_64-3.7
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/opt/[email protected]/include/mysql -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.14-x86_64-3.7/_mysql.o
  _mysql.c:252:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                          s = PyUnicode_AsUTF8(item);
                            ^ ~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:282:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                          s = PyUnicode_AsUTF8(item);
                            ^ ~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:571:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                  _stringsuck(ca, value, ssl);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:560: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(capath, value, ssl);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:560: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(cert, value, ssl);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:560:16: note: expanded from macro '_stringsuck'
          if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                 ^~~~~~~~~~~~~~~~~~~~
  _mysql.c:574:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                  _stringsuck(key, value, ssl);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:560:16: note: expanded from macro '_stringsuck'
          if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                 ^~~~~~~~~~~~~~~~~~~~
  _mysql.c:575:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                  _stringsuck(cipher, value, ssl);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  _mysql.c:560:16: note: expanded from macro '_stringsuck'
          if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                 ^~~~~~~~~~~~~~~~~~~~
  _mysql.c:2589: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 build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/opt/[email protected]/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/_mysql.cpython-37m-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
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    ERROR: Complete output from command /Users/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/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/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-record-bp84him0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zhaokun/Documents/Python/www/venv/django_site/bin/../include/site/python3.7/mysqlclient:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    copying _mysql_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb
    creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/opt/[email protected]/include/mysql -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.14-x86_64-3.7/_mysql.o
    _mysql.c:252:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                            s = PyUnicode_AsUTF8(item);
                              ^ ~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:282:6: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                            s = PyUnicode_AsUTF8(item);
                              ^ ~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:571:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(ca, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:560: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(capath, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:560: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(cert, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:560:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:574:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(key, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:560:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:575:3: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                    _stringsuck(cipher, value, ssl);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:560:16: note: expanded from macro '_stringsuck'
            if(t){d=PyUnicode_AsUTF8(t);ssl_keepref[n_ssl_keepref++]=t;}\
                   ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:2589: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 build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/opt/[email protected]/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/_mysql.cpython-37m-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
    ----------------------------------------
ERROR: Command "/Users/zhaokun/Documents/Python/www/venv/django_site/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/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/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-record-bp84him0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zhaokun/Documents/Python/www/venv/django_site/bin/../include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/ns/sj62hbw56cv68873x8_ck7gh0000gn/T/pip-install-vjn6m8ro/mysqlclient/

according to error message, l tried to run clang -v and get these information:

Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

l saw there are lots of question on stack overflow, and watched them, but they cannot solve my problem, l tried to run xcode-select install, and install another version of mysqlclient, all failed.

l also google it but also not the case fit me.

Now l really don't know what happened and how to solve it,

Upvotes: 2

Views: 1554

Answers (2)

Donald Nguyễn
Donald Nguyễn

Reputation: 21

LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient

Because openssl was dependency and this statement set path to it's required libs. (It would only work if openssl is already installed.)

Upvotes: 2

Legorooj
Legorooj

Reputation: 2757

The problem is here:

8 warnings generated.
    *this line->* clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/_mysql.o -L/usr/local/opt/[email protected]/lib -lmysqlclient *here ->* -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/_mysql.cpython-37m-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
    ----------------------------------------

Now what -lssl is or why it's a problem I can't figure out, but i would assume that you need to install the lssl library: ld: library not found for -lssl.

Upvotes: 0

Related Questions