How to work with MySQL client package in MacBook
On installing mysqlclient package you may face the following issue:
Collecting mysqlclient==2.2.0 (from -r requirements.txt (line 14))
Using cached mysqlclient-2.2.0.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
File "<string>", line 154, in <module>
File "<string>", line 48, in get_config_posix
File "<string>", line 27, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
To solve this you need to following things:
1. Check if brew is installed or not. If it is not installed then please install it from here (https://brew.sh/)
2. Then run this command: (brew install mysql-client) to install the package from your terminal
3. After installing the MySQL client, you might need to export some environment variables before running your installation command. Use the following commands to set the necessary variables: export PATH="/usr/local/opt/mysql-client/bin:$PATH" export LDFLAGS="-L/usr/local/opt/mysql-client/lib" export CPPFLAGS="-I/usr/local/opt/mysql-client/include"
4. Then if you are facing issue regarding pkg-config then Install pkg-config using Homebrew: brew install pkg-config
5. After doing all this if you are still facing the issue which is regarding: MySQLdb then you need to install pymysql package also and put these below lines in settings.py:
import pymysql pymysql.install_as_MySQLdb()

Comments
Post a Comment