gpt4 book ai didi

python - shell_plus 安装 Django 时出现错误 - ImportError : cannot import name 'Type

转载 作者:行者123 更新时间:2023-12-01 09:29:46 25 4
gpt4 key购买 nike

安装 django_extensions 后尝试启动 shell_plus 时出现以下错误。这是我遵循的步骤1-使用安装django_extensions

pip install django_extensions

2-向已安装的应用程序添加了 django_extensions

然后我收到以下错误

$ ./manage.py shell_plus           
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 216, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/commands/shell_plus.py", line 14, in <module>
from django_extensions.management.shells import import_objects
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/shells.py", line 5, in <module>
from typing import ( # NOQA
ImportError: cannot import name 'Type'

对可能出现的问题有什么建议吗?

最佳答案

Python 3.5 附带了自己的打字模块版本。最有可能发生的情况是,您在需求中指定了另一个类型模块(不包含 Type 类的模块),并且它被 django_extensions 而不是原生 Python 的模块选中。检查您安装的模块,或尝试运行:

pip uninstall typing

关于python - shell_plus 安装 Django 时出现错误 - ImportError : cannot import name 'Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50072672/

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