54👍
I needed the following to build / install mysqlclient
brew install mysql-client
# mysql-client is not on the `PATH` by default
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
# openssl is not on the link path by default
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
Then I could pip wheel mysqlclient
/ pip install mysqlclient
successfully
27👍
I have encountered this problem too,below is my step:
1.brew install mysql-connector-c
2.pip install mysqlclient
and then encountered this error,i have Traced the source code,but solved this one then the other error occured.
so i changed the way to install mysqlclient,just :
1.brew install mysql
2.pip install mysqlclient
this worked for me,no any errors occured.
- [Django]-Django-rest-framework: Cannot call `.is_valid()` as no `data=` keyword argument was passed when instantiating the serializer instance
- [Django]-DEBUG = True Django
- [Django]-How to Lazy Load a model in a managers to stop circular imports?
15👍
Install mysql-client
instead of mysql
if you don’t plan to have mysql
in your computer
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient
export LDFLAGS=”-L/usr/local/opt/openssl/lib”
export CPPFLAGS=”-I/usr/local/opt/openssl/include”
- [Django]-How to force Django Admin to use select_related?
- [Django]-Django : Is it impossible to static tag into block tag?
- [Django]-Django – how to detect test environment (check / determine if tests are being run)
13👍
brew install/upgrade/reinstall mysql
brew install mysql-client
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install mysqlclient
works perfectly
- [Django]-What is pip install -q -e . for in this Travis-CI build tutorial?
- [Django]-Sending emails with attachment in django
- [Django]-How to convert JSON data into a Python object?
7👍
For Mac:
first download Xcode from App Store and MySqlWorkbench from https://dev.mysql.com/downloads/workbench/
Run the following commands in terminal,
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
- [Django]-How to force migrations to a DB if some tables already exist in Django?
- [Django]-Override existing Django Template Tags
- [Django]-Success_url in UpdateView, based on passed value
3👍
Install mysql using brew and add it to the path:
$ brew install mysql
$ export PATH=/usr/local/mysql/bin:$PATH
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
$ pip install mysqlclient
- [Django]-Django ManyToManyField ordering using through
- [Django]-Django custom managers – how do I return only objects created by the logged-in user?
- [Django]-Django translate variable content in template
2👍
This worked for me today, after using brew install mysql
to install the MySQL server using Homebrew:
MYSQLCLIENT_CFLAGS=`pkg-config mysqlclient --cflags` \
MYSQLCLIENT_LDFLAGS=`pkg-config mysqlclient --libs` \
pip install mysqlclient
- [Django]-Django doesn't call model clean method
- [Django]-Django test VS pytest
- [Django]-Django select_related – when to use it
0👍
For my mac os,
I need not to specify the path because brew do that for you.
I just did below commands,
brew install mysql
brew install mysql-client
pip3 install mysqlclient
Everything is perfect & fine.
- [Django]-Django templates: loop through and print all available properties of an object?
- [Django]-Django ORM – objects.filter() vs. objects.all().filter() – which one is preferred?
- [Django]-Django annotate() multiple times causes wrong answers
- [Django]-NameError: name '_mysql' is not defined after setting change to mysql
- [Django]-Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT
- [Django]-Is it better to use path() or url() in urls.py for django 2.0?
0👍
brew info mysql-client
might be the most future-proof way to find out what variables you need to set before you can install the mysqlclient
package.
None of the answers here worked for me. After running brew install mysql-client
, I then tried brew info mysql-client
. The relevant section of its output was:
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /opt/homebrew,
because it conflicts with mysql (which contains client libraries).
If you need to have mysql-client first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"
For pkg-config to find mysql-client you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"
After running the exports described above, pip install mysqlclient
worked.
- [Django]-Can't install Django 2.0 by pip
- [Django]-NoReverseMatch Error
- [Django]-Django admin – make all fields readonly
0👍
The flags were slightly different for me
brew install mysql
export MYSQLCLIENT_CFLAGS="-I/opt/homebrew/opt/mysql/include/mysql"
export MYSQLCLIENT_LDFLAGS="-L/opt/homebrew/opt/mysql/lib"
pip install mysqlclient
- [Django]-Django sort by distance
- [Django]-Lazy choices in Django form
- [Django]-Django – Clean permission table