问题描述
我正在建立一个网站,并试图创建一个自定义的用户到用户消息传递系统,所以我安装了,也许还有其他一些事情,突然,当我尝试运行服务器时,出现以下错误:
I'm building a website and I was trying to create a custom user-to-user messaging system so I installed django-messages and maybe a few other things, and suddenly when I tried to run my server I get the following error :
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\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 "C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django_messages\models.py", line 9, in <module>
from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (C:\Users\mertz\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\encoding.py)
在我看来这是中文,我不明白此错误的任何一行,有人可以帮助我吗?
我进行了一些研究,它似乎与程序包名称 6
有关,但是我找不到解决方案。我可以为您提供我的代码,但我不知道您需要哪个文件,因此随时在评论中索取一个文件,然后我将相应地编辑我的帖子。
It sounds like chinese to me, I don't understand a single line of this error, can someone help me ?I've made a few researchs, it looks like it's related to a package name six
but I was not able to find a solution. I can provide you my code if it's needed but I don't know which file you need so feel free to ask for a file in the comments and I will edit my post accordingly.
预先感谢!
推荐答案
您正在使用Django 3,其中所有 。 django消息
仍然依赖于这些消息,并且正在尝试并且无法导入它们。
You are using Django 3, where all the Python 2 compatibility APIs that used to be bundled with Django were removed. django-messages
still depends on these, and is trying and failing to import them.
您要么需要降级到Django 2.2,或等待 django-messages
更新以获取Django 3支持。
You either need to downgrade to Django 2.2, or wait for django-messages
to be updated for Django 3 support.
库中出现此类错误-这意味着该库与Django 3尚不兼容。
This applies for any library in which you get such errors - it means the library is not compatible yet with Django 3.
这篇关于Django ImportError:无法导入名称“ python_2_unicode_compatible”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!