运行2to3并将所有软件包安装在settings.py(和requirements.txt)中后,在检查或运行服务器时出现此错误。
(env) x:languages x$ python3 manage.py check
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/project/src/languages/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/project/src/languages/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/project/src/languages/env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/project/src/languages/env/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 "/project/src/languages/language/__init__.py", line 3, in <module>
from django_comments.models import Comment
File "/project/src/languages/env/lib/python3.7/site-packages/django_comments/models.py", line 7, in <module>
from .abstracts import (
File "/project/src/languages/env/lib/python3.7/site-packages/django_comments/abstracts.py", line 4, in <module>
from django.contrib.contenttypes.fields import GenericForeignKey
File "/project/src/languages/env/lib/python3.7/site-packages/django/contrib/contenttypes/fields.py", line 3, in <module>
from django.contrib.contenttypes.models import ContentType
File "/project/src/languages/env/lib/python3.7/site-packages/django/contrib/contenttypes/models.py", line 133, in <module>
class ContentType(models.Model):
File "/project/src/languages/env/lib/python3.7/site-packages/django/db/models/base.py", line 103, in __new__
app_config = apps.get_containing_app_config(module)
File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
使用pip3为原始项目(在Python2中)安装了requirements.txt,产生了此模块安装错误,尽管我不确定这是否完全相关。
Collecting MySQL-python==1.2.5
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
ERROR: Command errored out with exit status 1:
command: /project/src/languages/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/setup.py'"'"'; __file__='"'"'/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/pip-egg-info
cwd: /private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-a0orkyii/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
对于项目的原始Python2版本,以上内容不是问题。