报错如下
ImportError: dlopen(/Users/john/PycharmProjects/llknew/venv/lib/python3.10/site-packages/MySQLdb/_mysql.cpython-310-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/john/PycharmProjects/llknew/venv/lib/python3.10/site-packages/MySQLdb/_mysql.cpython-310-darwin.so
Reason: image not found
解决方法
进入到虚拟环境venv的这个目录下
venv/lib/python3.10/site-packages/MySQLdb
然后执行命令
otool -L _mysql.cpython-310-darwin.so
然后执行命令
install_name_tool -change @rpath/libmysqlclient.21.dylib /usr/local/mysql/lib/libmysqlclient.21.dylib _mysql.cpython-310-darwin.so
再试试
问题解决
网友评论