Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS Sierra virtualenv (python 2.7) pip install mysqlclient error

On Mac OS Sierra, created virtualenv using python2.7 and trying to install mysqlclient to use Django w/ MySQL. I installed MySQL 5.6 via homebrew. Running "pip install mysqlclient" gives these errors:

Running setup.py bdist_wheel for mysqlclient ... error
...
 13 warnings generated.
  cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
  ld: library not found for -lssl
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'cc' failed with exit status 1

  Failed building wheel for mysqlclient
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/

Any help would be greatly appreciated.

like image 619
Initial Commit Avatar asked Oct 31 '16 18:10

Initial Commit


People also ask

Can't pip install Mysqlclient?

First, check that you are connected to the internet and it is stable. Try to run the command again. Next, you will have to manually download and install the package if the problem persists. To do this, you can Google the binary file of mysqlclient that is compatible with your device, or you can go to this site.

What is Mysqlclient in python?

mysqlclient is a fork of MySQL-python. It adds Python 3 support and fixed many bugs. MySQLdb is an interface to the popular MySQL database server for Python. The design goals are: Compliance with Python database API version 2.0 [PEP-0249]


2 Answers

The answer was installing dev tools using:

xcode-select --install

like image 119
Initial Commit Avatar answered Sep 28 '22 01:09

Initial Commit


In my case I needed to do two steps:

xcode-select --install

as @howevilweare says AND also pip install with the brew installed openssl using an env command:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient
like image 20
Rob Osborne Avatar answered Sep 28 '22 02:09

Rob Osborne