gpt4 book ai didi

django - 导入错误 : cannot import name 'force_unicode' caused another exception

转载 作者:行者123 更新时间:2023-12-04 12:05:47 24 4
gpt4 key购买 nike

我在我的 django 应用程序中玩日历,所以我做了一个:

pip3 安装 django-scheduler

( https://github.com/llazzaro/django-scheduler )

我做我通常的 python3 manage.py runserver 的那一刻它失败了,这个长异常:

Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/filer/utils/compatibility.py", line 71, in <module>
from django.utils.encoding import force_unicode # noqa
ImportError: cannot import name 'force_unicode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/shane/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/shane/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/shane/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/shane/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/shane/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/shane/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/shane/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/shane/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/filer/models/__init__.py", line 2, in <module>
from .clipboardmodels import * # noqa
File "/usr/local/lib/python3.6/dist-packages/filer/models/clipboardmodels.py", line 8, in <module>
from ..utils.compatibility import python_2_unicode_compatible
File "/usr/local/lib/python3.6/dist-packages/filer/utils/compatibility.py", line 86, in <module>
from django.utils.encoding import python_2_unicode_compatible # noqa
ImportError: cannot import name 'python_2_unicode_compatible'

我想'哦不,没问题我只是 pip3 卸载 django_scheduler'

好吧,我这样做了(在我的 INSTALLED_APPS 中删除了“计划”的添加)并尝试重新运行,但再次出现相同的错误。那么我是否只是无可救药地破坏了我的整个项目?

Python 版本为:3.6.8
Django 版本:3.0.6

我很高兴地编码,直到我有一个尝试使用 django 库来实现我需要实现的日历而不是仅仅编写我自己的脑电波:/

最佳答案

有一个不适用于此功能的向后兼容性 promise

只需更换 force_unicodeforce_text如果您使用最近的 Django 版本。

它在 py2 和 py3 上都适用于 Django1.11。

关于django - 导入错误 : cannot import name 'force_unicode' caused another exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61738019/

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