因此,我是Django的新手,我正在使用指南来创建一个简单的电子商务网站。 我的问题是我一直收到ValueError,但不确定如何解决此问题。 这是我的manage.py文件
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rdewebsite.settings.dev")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
我得到的错误在这里:
Ernestass-MacBook-Pro:rdewebsite ernekz$ python3 manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 60, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/urls/resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/urls/resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/3.7/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/ernekz/Desktop/Python/rdewebsite/rdewebsite/urls.py", line 5, in <module>
from wagtail.admin import urls as wagtailadmin_urls
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/admin/urls/__init__.py", line 11, in <module>
from wagtail.admin.urls import password_reset as wagtailadmin_password_reset_urls
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/admin/urls/password_reset.py", line 3, in <module>
from wagtail.admin.views import account
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/admin/views/account.py", line 14, in <module>
from wagtail.users.forms import (
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/users/forms.py", line 24, in <module>
from wagtail.utils import l18n
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/utils/l18n/__init__.py", line 3, in <module>
from .maps import tz_cities, tz_fullnames, territories
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/utils/l18n/maps.py", line 3, in <module>
from .translation import L18NMap, L18NListMap
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/utils/l18n/translation.py", line 50, in <module>
_trans = Trans()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wagtail/utils/l18n/translation.py", line 16, in __init__
self.set(getdefaultlocale()[0])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 568, in getdefaultlocale
return _parse_localename(localename)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 495, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Django版本为2.1.3 Python版本是3.7.0 我也尝试在/.bashprofile中使用它们,但对我没有任何帮助
export LC_ALL = zh_CN.UTF-8
export LANG = zh_CN.UTF-8
也许有些人有类似的错误。谢谢!