Mac版Pycharm无法连接数据库

来源:3-2 配置表单页面

昭昭li

2017-03-01

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/lijianzhao/Documents/Py_Env/py2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib

  Referenced from: /Users/lijianzhao/Documents/Py_Env/py2.7/lib/python2.7/site-packages/_mysql.so

  Reason: image not found


写回答

1回答

矢寸心

2017-03-01

试试下面的方法,其中mysql-....-x86_64目录名称取决于你安装的MySQL以及当前Mac版本

sudo ln -s /Users/lijianzhao/Documents/mysql-....-x86_64/lib/libmysqlclient.20.dylib /usr/local/opt/mysql/lib/libmysqlclient.20.dylib

0
1
昭昭li
已经解决了,pip install mysqlclient,用mysqlclient 取代 python-mysql就好
2017-03-01
共1条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程