正在创建多个不兼容的 InteractiveShellEmbed 子类实例

2023-12-30

如果我安装Anaconda Python 发行版 http://docs.continuum.io/anaconda/并尝试运行ipython manage.py shell从我的 Django 应用程序中,抛出以下错误。我知道当我安装 anaconda 时,它附带了 python 和 ipython,其版本与我拥有的其他 python/ipython 版本不同。但无论 ipython 版本如何,为什么 django shell 会抛出错误?我尝试卸载系统 ipython 并抛出相同的错误,这意味着 anaconda ipython 发行版和 django 存在一些问题。卸载 anaconda 可以解决问题。

堆栈跟踪

manage.py in <module>()
      9 
     10 if __name__ == "__main__":
---> 11     execute_manager(settings)

lib/python2.7/site-packages/django/core/management/__init__.pyc in execute_manager(settings_mod, argv)
    457     setup_environ(settings_mod)
    458     utility = ManagementUtility(argv)
--> 459     utility.execute()

lib/python2.7/site-packages/django/core/management/__init__.pyc in execute(self)
    380             sys.stdout.write(self.main_help_text() + '\n')
    381         else:
--> 382             self.fetch_command(subcommand).run_from_argv(self.argv)
    383 
    384 def setup_environ(settings_mod, original_settings_path=None):

lib/python2.7/site-packages/django/core/management/base.pyc in run_from_argv(self, argv)
    194         options, args = parser.parse_args(argv[2:])
    195         handle_default_options(options)
--> 196         self.execute(*args, **options.__dict__)
    197 
    198     def execute(self, *args, **options):

lib/python2.7/site-packages/django/core/management/base.pyc in execute(self, *args, **options)
    230             if self.requires_model_validation:
    231                 self.validate()
--> 232             output = self.handle(*args, **options)
    233             if output:
    234                 if self.output_transaction:

lib/python2.7/site-packages/django/core/management/base.pyc in handle(self, *args, **options)
    369         if args:
    370             raise CommandError("Command doesn't accept any arguments")
--> 371         return self.handle_noargs(**options)
    372 
    373     def handle_noargs(self, **options):

lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in handle_noargs(self, **options)
    116                 try:
    117                     from IPython import embed
--> 118                     embed(user_ns=imported_objects)
    119                 except ImportError:
    120                     # IPython < 0.11

lib/python2.7/site-packages/IPython/terminal/embed.pyc in embed(**kwargs)
    298         config.InteractiveShellEmbed = config.TerminalInteractiveShell
    299         kwargs['config'] = config
--> 300     shell = InteractiveShellEmbed.instance(**kwargs)
    301     shell(header=header, stack_depth=2, compile_flags=compile_flags)

lib/python2.7/site-packages/IPython/config/configurable.pyc in instance(cls, *args, **kwargs)
    358             raise MultipleInstanceError(
    359                 'Multiple incompatible subclass instances of '
--> 360                 '%s are being created.' % cls.__name__
    361             )
    362 

MultipleInstanceError: Multiple incompatible subclass instances of InteractiveShellEmbed are being created.

你想使用

python manage.py shell

not

ipython manage.py shell

manage.pyshell 启动一个嵌入式 IPython 实例。当你通过运行这个ipython manage.py,您将启动常规 IPython 会话,在其中运行尝试嵌入 IPython 的脚本。这意味着您正在启动两个 IPython 实例。这会失败,因为 IPython 无法嵌入其自身。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

正在创建多个不兼容的 InteractiveShellEmbed 子类实例 的相关文章

随机推荐