gpt4 book ai didi

python - Django2.1.7 ImportError : cannot import name 'util' from 'django.forms' (/Users/lib/python3. 7/site-packages/django/forms/__init__.py)

转载 作者:行者123 更新时间:2023-12-01 08:20:05 25 4
gpt4 key购买 nike

在从 Django1.5 迁移到 Django2.1.7 的过程中,当我们尝试启动服务器时,我们在库函数中遇到了隐式导入错误。

Traceback (most recent call last):
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10945f950>
Traceback (most recent call last):
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/Users/MAK/Envs/lifemed3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/json_field/__init__.py", line 1, in <module>
from json_field.fields import JSONField
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/json_field/fields.py", line 4, in <module>
from json_field.forms import JSONFormField
File "/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/json_field/forms.py", line 5, in <module>
from django.forms import fields, util
ImportError: cannot import name 'util' from 'django.forms' (/Users/MAK/Envs/lifemed3/lib/python3.7/site-packages/django/forms/__init__.py)

我们已经检查过这个answer关于循环依赖,但因为它是在代码级别并且很容易解决,但就库而言,解决这个问题的最佳方法是什么?

仅供引用:我们正在从 python 2.7 和 django 1.5.5 迁移到 python3.7 和 Django2.1.7

UPDATE (Solved)

根据 mfrackowiak 的 answer下面我们要 fork 他们的repo ,应用patch感谢支持和install来自changed version 。然后它对我有用

最佳答案

看来package很长一段时间没有维护,处理此错误的最佳方法是查找 alternatives或者只是 fork 存储库并自己更新它,这样它仍然可以工作(可能比调整另一个库的代码库更容易)。

关于python - Django2.1.7 ImportError : cannot import name 'util' from 'django.forms' (/Users/lib/python3. 7/site-packages/django/forms/__init__.py),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54705648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com