MacOS 下 Django 项目 makemigrations 时提示 image not found

MacOS 下 Django 项目 makemigrations 时提示 image not found

每次连接 Mysql 都会有问题

Django 执行 python manage.py makemigrations myapp 时出现下面的问题

ImportError: dlopen(/Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql-connector-c/lib/libmysqlclient.18.dylib
Referenced from: /Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
Reason: image not found

ImportError: dlopen(/Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
Reason: image not found

ImportError: dlopen(/Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /Users/mac/.local/share/virtualenvs/ming-6rjZE-CY/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
Reason: image not found

确认已经安装了 mysqlopenssl

brew install mysql # 
brew install openssl

添加相应的符号链接

ln -s /usr/local/Cellar/mysql/8.0.18_1/lib/libmysqlclient.21.dylib libmysqlclient.18.dylib
ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib libssl.1.0.0.dylib
ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib libcrypto.1.0.0.dylib

参考:

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×