Python写入连接mysql失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python写入连接mysql失败相关的知识,希望对你有一定的参考价值。
执行如下连接数据库的语句:
engine = create_engine(‘mysql://root:[email protected]/stock?charset=utf8‘)
报错如下:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so, 2): Library not loaded: libmysqlclient.18.dylib Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so Reason: image not found
解决办法:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
参考Stack Overflow:https://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib
以上是关于Python写入连接mysql失败的主要内容,如果未能解决你的问题,请参考以下文章