Trying to install mysqlclient using pip3 on Python 3.6.0
$ pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Comp
This worked for me on MacOS 10+. Rather than directly installing mysqlclient using pip, use this command first
brew install mysql
If you do not have an existing setup for brew, then install brew from it's homepage
Then run
pip install mysqlclient
This should work! Also ensure you have a virtualenv set up for your projects, as it is among good practices to maintain venv's for each project seperately.
Came across this while developing a django-based website, and I needed to set up the website to communicate with a mysql database. I've not used homebrew to do any of my installations.
Since I'm doing the development on a MacOS with Anaconda installed, I discovered that there was an issue with Anaconda. Without knowing the details, I was able to install mysqlclient with conda install mysqlclient
Hope that helps someone else with this problem as well.
Other options didn't work for me, but this worked for me:
For Python3:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip3 install mysqlclient
For Python2:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip2 install mysqlclient
or
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient