Skip to content

Instantly share code, notes, and snippets.

@jessamynsmith
Created September 27, 2018 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessamynsmith/32afb8a05d7b59965e6dbf48852acabc to your computer and use it in GitHub Desktop.
Save jessamynsmith/32afb8a05d7b59965e6dbf48852acabc to your computer and use it in GitHub Desktop.
Installing mysqlclient with python3 on OSX
$ pip install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /Users/jessamyn/.virtualenvs/django-mysql-test/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-install-0d9salg8/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/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-wheel-bgng27ta --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.macosx-10.12-x86_64-3.6
creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.12-x86_64-3.6
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql/5.7.21/include/mysql -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.12-x86_64-3.6/_mysql.o
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-3.6/_mysql.o -L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-3.6/_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
----------------------------------------
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
Complete output from command /Users/jessamyn/.virtualenvs/django-mysql-test/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-install-0d9salg8/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/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-record-ttrc4jaq/install-record.txt --single-version-externally-managed --compile --install-headers /Users/jessamyn/.virtualenvs/django-mysql-test/bin/../include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.macosx-10.12-x86_64-3.6
creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb
creating build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.12-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.12-x86_64-3.6
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql/5.7.21/include/mysql -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.12-x86_64-3.6/_mysql.o
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-3.6/_mysql.o -L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-3.6/_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
----------------------------------------
Command "/Users/jessamyn/.virtualenvs/django-mysql-test/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-install-0d9salg8/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/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-record-ttrc4jaq/install-record.txt --single-version-externally-managed --compile --install-headers /Users/jessamyn/.virtualenvs/django-mysql-test/bin/../include/site/python3.6/mysqlclient" failed with error code 1 in /private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-install-0d9salg8/mysqlclient/
$ brew info openssl
openssl: stable 1.0.2p (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2l (1,709 files, 12.2MB)
Poured from bottle on 2017-05-27 at 19:59:54
/usr/local/Cellar/openssl/1.0.2m (1,792 files, 12.3MB)
Poured from bottle on 2017-11-19 at 16:25:42
/usr/local/Cellar/openssl/1.0.2n (1,792 files, 12.3MB)
Poured from bottle on 2017-12-14 at 21:57:59
/usr/local/Cellar/openssl/1.0.2o_1 (1,791 files, 12.3MB)
Poured from bottle on 2018-04-08 at 20:01:55
/usr/local/Cellar/openssl/1.0.2o_2 (1,792 files, 12.3MB)
Poured from bottle on 2018-07-08 at 17:36:58
/usr/local/Cellar/openssl/1.0.2p (1,793 files, 12.3MB)
Poured from bottle on 2018-09-03 at 15:27:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Dependencies
Build: makedepend ✘
==> Options
--without-test
Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
==> Analytics
install: 556,055 (30d), 1,491,119 (90d), 4,803,757 (365d)
install_on_request: 75,371 (30d), 212,774 (90d), 546,010 (365d)
build_error: 13,954 (30d)
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
$ pip install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... done
Stored in directory: /Users/jessamyn/Library/Caches/pip/wheels/71/9b/6f/a8c79bceb4a35f4acf49363883f958f31b113470a3b504df87
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.13
$ python
Python 3.6.5 (default, Mar 30 2018, 06:42:10)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment