1
votes

I'm unable to 'pip install mysqlclient', and every attempt returns the error: 'ERROR: Failed building wheel for mysqlclient'. For context, I'm running on macOS Mojave 10.14.5. The rest of this post assumes that both 'python==3.6' and 'virtualenv' are already downloaded. In addition, x-code command line tools are already installed (not that I think that matters).

The steps to this are (from command line):

  1. 'virtualenv ~/venv'

    • Output:

    Using base prefix '/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6' New python executable in /Users/usr1/venv/bin/python3.6 Also creating executable in /Users/usr1/venv/bin/python Installing setuptools, pip, wheel...done."

  2. 'source ~/venv/bin/activate'

  3. 'pip install mysqlclient'

So far, I've viewed and attempted everything on:

  1. Failed building wheel for mysqlclient

  2. "Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

  3. Failed building wheel for mysql-python

    Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error ERROR: Complete output from command /Users/usr1/venv/bin/python3.6 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/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/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-wheel-ehvuw9uv --python-tag cp36: ERROR: running bdist_wheel running build running build_py creating build creating 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/_exceptions.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 running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.13-x86_64-3.6 creating build/temp.macosx-10.13-x86_64-3.6/MySQLdb clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql/5.7.19/include/mysql -I/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.o clang -bundle -undefined dynamic_lookup build/temp.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/5.7.19/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.cpython-36m-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/usr1/venv/bin/python3.6 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/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/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-record-zvd4oedq/install-record.txt --single-version-externally-managed --compile --install-headers /Users/usr1/venv/bin/../include/site/python3.6/mysqlclient: ERROR: running install running build running build_py creating build creating 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/_exceptions.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 running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.13-x86_64-3.6 creating build/temp.macosx-10.13-x86_64-3.6/MySQLdb clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql/5.7.19/include/mysql -I/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.o clang -bundle -undefined dynamic_lookup build/temp.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/5.7.19/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.13-x86_64-3.6/MySQLdb/_mysql.cpython-36m-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/usr1/venv/bin/python3.6 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/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/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-record-zvd4oedq/install-record.txt --single-version-externally-managed --compile --install-headers /Users/usr1/venv/bin/../include/site/python3.6/mysqlclient" failed with error code 1 in /private/var/folders/2j/1qt0_7q96lxbxl2w5kx8r1zr0000gn/T/pip-install-4uobjq_4/mysqlclient/

CONCLUSION: Ideally, I would like for 'pip' to simply install 'mysqlclient'. I would very much appreciate the help. Thanks in advance.

3

3 Answers

1
votes

Only need to install dev version of python with:

sudo apt-get install python3-dev

ERROR: Failed building wheel for mysqlclient

0
votes

Download mysqlclient.whl from this Python Extension Package for Windows and install with pip install mysqlclient‑1.4.2‑cp36‑cp36m‑win_amd64.whl

0
votes

I have seen this line in your error response

ld: library not found for -lssl clang: error: linker command failed with exit code 1

Trust me, I have spent a long time figuring above error out. I have already answered a similar question, do refer this link. It might solve your problem,

P.S: I don't have much reputation to comment on your post, so posting as an answer, Apologies.