Spyder 未以 TypeError 开头:__init__() 缺少 1 个必需的位置参数
Posted
技术标签:
【中文标题】Spyder 未以 TypeError 开头:__init__() 缺少 1 个必需的位置参数【英文标题】:Spyder not starting with TypeError: __init__() missing 1 required positional argument 【发布时间】:2021-07-03 04:42:12 【问题描述】:我的问题似乎与this one 有关,但我的问题更糟,因为 Spyder 5 根本没有启动。也许是因为它在 Mac Os 上运行?
运行/Library/Frameworks/Python.framework/Versions/3.9/bin/spyder &
时,闪屏短暂出现,然后又消失,我收到错误消息:
MacIgor:~ igor$ No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/spyder", line 8, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/app/start.py", line 213, in main
mainwindow.main(options, args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/app/mainwindow.py", line 2293, in main
mainwindow = create_window(app, splash, options, args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/app/mainwindow.py", line 2155, in create_window
main.pre_visible_setup()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/app/mainwindow.py", line 1186, in pre_visible_setup
plugin_instance.before_mainwindow_visible()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/plugin.py", line 133, in before_mainwindow_visible
self.setup_layout(default=False)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/plugin.py", line 237, in setup_layout
self.set_window_settings(*settings)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/plugin.py", line 435, in set_window_settings
self.setup_layout(default=True)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/plugin.py", line 210, in setup_layout
self.setup_default_layouts('default', settings)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/plugin.py", line 276, in setup_default_layouts
layout.set_main_window_layout(self.main, self.get_dockable_plugins())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/layout/api.py", line 381, in set_main_window_layout
plugin.toggle_view(area["visible"])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 508, in toggle_view
self.create_new_client(give_focus=False)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 1007, in create_new_client
self.connect_client_to_kernel(client, is_cython=is_cython,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 1041, in connect_client_to_kernel
km, kc = self.create_kernel_manager_and_kernel_client(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 1506, in create_kernel_manager_and_kernel_client
kernel_client.hb_channel.time_to_dead = 25.0
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/jupyter_client/client.py", line 364, in hb_channel
self._hb_channel = self.hb_channel_class(self.context, self.session, url)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/qtconsole/util.py", line 64, in __new__
QClass.__init__(inst)
TypeError: __init__() missing 1 required positional argument: 'context'
我之前在 Mac OS High Sierra 上使用过 Spyder 4.* 和 Python 3.* 没有问题。在将 Python 升级到 3.9.4(以前是 3.7.7)和 Spyder 升级到 5 后,今天开始出现问题。
是否有解决方法,还有什么我应该检查/更新的吗?
【问题讨论】:
【参考方案1】:(这里是 Spyder 维护者) 这是最新版jupyter_client
产生的问题。在发布新版本之前,请使用以下命令安装最后一个工作版本:
pip install jupyter_client==6.1.12
【讨论】:
我刚刚恢复到 4.2.5,它又可以工作了。不过谢谢。以上是关于Spyder 未以 TypeError 开头:__init__() 缺少 1 个必需的位置参数的主要内容,如果未能解决你的问题,请参考以下文章
更新到 Spyder 4.1.4 后 Spyder 返回 TypeError
Alamofire 文件上传出现错误“JSON 文本未以数组或对象开头,并且允许未设置片段的选项”
Spyder调试错误-"TypeError: decoding Unicode is not supported"
在 Ubuntu 18.04 上,RabbitMQ 未以消息“init terminating in do_boot,noproc”开头