Description:
Platform: macOS Catalina.
Virtual Environments: virtualenv
IDE: PyCharm
Steps:
- Install MySQL by HomeBrew
brew install mysql
2. Set your username and password of MySQL
mysqladmin -u root password "YOURPASSWORD"
Normally, if you install Python module “mysqlclient” immediately, following problem may occour
......
Running setup.py install for mysqlclient … error
......
clang: error: linker command failed with exit code 1 (use -v to see invocation)
......
So to avoid it, you should continue configuring according to step3 and step4.
3. Configure the OpenSSL
brew info openssl
Information given below such as this
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
Add the information to ~/.bash_profile(if you use default bash) or ~/.zshrc(if you use zsh) and then “source” them.
4. Install “mysqlclient” through pip3.
pip3 install mysqlclient
That’s all done, start coding.