问题描述
我的团队正在使用 MysqL 开发 Django 项目。
我已经克隆了一个项目存储库并安装了所有依赖项,但是,当我使用 python3 manage.py runserver
运行该项目时,出现以下错误:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MysqLdb/__init__.py",line 18,in <module>
from . import _MysqL
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MysqLdb/_MysqL.cpython-38-darwin.so,2): Library not loaded: @rpath/libMysqLclient.21.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MysqLdb/_MysqL.cpython-38-darwin.so
Reason: image not found
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py",line 932,in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py",line 870,in run
self._target(*self._args,**self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/utils/autoreload.py",line 53,in wrapper
fn(*args,**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/commands/runserver.py",line 117,in inner_run
self.check(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/base.py",line 392,in check
all_issues = self._run_checks(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/base.py",line 382,in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/checks/registry.py",line 72,in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/checks/model_checks.py",line 34,in check_all_models
errors.extend(model.check(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/base.py",line 1259,in check
*cls._check_long_column_names(),File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/base.py",line 1780,in _check_long_column_names
connection = connections[db]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/utils.py",line 207,in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/utils.py",line 111,in load_backend
return import_module('%s.base' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py",line 127,in import_module
return _bootstrap._gcd_import(name[level:],package,level)
File "<frozen importlib._bootstrap>",line 1014,in _gcd_import
File "<frozen importlib._bootstrap>",line 991,in _find_and_load
File "<frozen importlib._bootstrap>",line 975,in _find_and_load_unlocked
File "<frozen importlib._bootstrap>",line 671,in _load_unlocked
File "<frozen importlib._bootstrap_external>",line 783,in exec_module
File "<frozen importlib._bootstrap>",line 219,in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/backends/MysqL/base.py",line 16,in <module>
import MysqLdb as Database
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MysqLdb/__init__.py",line 24,in <module>
version_info,_MysqL.version_info,_MysqL.__file__
NameError: name '_MysqL' is not defined
正在开发新的 Mac M1 操作系统 11.0.1 版
尝试使用 sudo ln -s /usr/local/MysqL/lib/libMysqLclient.21.dylib /usr/local/lib/libMysqLclient.21.dylib
解决问题,但没有奏效。
MysqL 已安装,检查 libMysqLclient.21.dylib
和 _MysqL.cpython-38-darwin.so
是否存在于相应目录中。
还尝试使用 install-name-tool
更改 @rpath
,但也没有运气。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)