用Django安装的shell_plus给出错误 - ImportError:无法导入名称'类型

时间:2018-04-28 03:52:44

标签: python django django-extensions

在安装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'

有关可能出现的问题的任何建议?

1 个答案:

答案 0 :(得分:1)

Python 3.5附带了自己的输入模块版本。最有可能发生的事情是你的需求中指定了另一个输入模块(不包含Type类的模块),并且它被django_extensions而不是本机Python获取。检查已安装的模块,或尝试运行:

pip uninstall typing