Mac上brew安装Python和mysqlclient
今日想研究下Django框架,需要配置合适的Python环境。虽然Mac系统默认安装了Python,但由于各种系统权限问题,导致安装各种库时会出现很多奇奇怪怪的问题。因此,推荐使用brew另外安装一个Python,这样各种控制就很灵活了。
brew install python安装Python 2.7;- 输入命令验证安装,如果
which python返回/usr/local/bin/python和which easy_install返回/usr/local/bin/easy_install,证明安装正确; - 通过easy_install安装pip
easy_install pip; Python默认支持SQLite,但平时使用最多是MySQL,需要安装mysqlclient,pip install mysqlclient;- 如果安装过程中提示
not found mysql_config,就需要将export PATH="$PATH":/usr/local/mysql/bin添加到.bash_profile或者.zshrc中,再执行pip install mysqlclient就可以安装了; - 如果在链接
MySQL时提示Library not loaded: libmysqlclient.18.dylib,就需要将export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"添加到.bash_profile或者.zshrc中就可以了。