类型错误:启动 Spyder 5.2.2 时出现预期字符串或类似字节的对象
我使用 Spyder 5.2.2 和 Python 3.10.2 在 conda 中创建了一个新环境。现在,我遇到一个错误,告诉我程序在启动 Spyder 时需要一个字符串或类似字节的对象。有趣的是,当我的 Python 是 3.9.* 时,这种情况不会发生。有什么原因会发生这种情况吗?
这是遇到的错误:
(py10) PS C:\Users\Kevin Yew> spyder
Traceback (most recent call last):
File "C:\Users\Kevin Yew\anaconda3\envs\py10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\app\start.py", line 233, in main
from spyder.app import mainwindow
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\app\mainwindow.py", line 41, in <module>
requirements.check_qt()
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\requirements.py", line 47, in check_qt
if parse_version(actual_ver) < parse_version(required_ver):
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\pkg_resources\__init__.py", line 120, in parse_version
return packaging.version.Version(v)
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\pkg_resources\_vendor\packaging\version.py", line 264, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
编辑 这是您可以尝试重现错误的代码。
conda create -n py10 python=3.10.2
conda activate py10
conda install spyder
spyder
I created a new environment in conda with Spyder 5.2.2 and Python 3.10.2. Now, I'm experiencing an error telling me that the program expects a string or byte-like object while starting the Spyder. Interestingly, this does not happen when my Python is 3.9.* . Any reason this can happen?
Here is the error encountered:
(py10) PS C:\Users\Kevin Yew> spyder
Traceback (most recent call last):
File "C:\Users\Kevin Yew\anaconda3\envs\py10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\app\start.py", line 233, in main
from spyder.app import mainwindow
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\app\mainwindow.py", line 41, in <module>
requirements.check_qt()
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\spyder\requirements.py", line 47, in check_qt
if parse_version(actual_ver) < parse_version(required_ver):
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\pkg_resources\__init__.py", line 120, in parse_version
return packaging.version.Version(v)
File "C:\Users\Kevin Yew\anaconda3\envs\py10\lib\site-packages\pkg_resources\_vendor\packaging\version.py", line 264, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
Edit
Here's the code you can try to reproduce the error.
conda create -n py10 python=3.10.2
conda activate py10
conda install spyder
spyder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(这里是 Spyder 维护者)这是检查 PyQt5 是否存在的代码中的错误,它将在我们将于 2022 年 3 月发布的下一个版本 (5.3.0) 中修复(请参阅 此处)。
(Spyder maintainer here) This is an error in the code that checks if PyQt5 is present and it will be fixed in our next version (5.3.0) to be released in March 2022 (see here).
我浏览了有关 Spyder 问题的帖子,显然,它涉及升级或降级某些软件包来解决 Spyder 运行问题。当我查看 Anaconda Navigator 中的可更新包时,PyQt 和 Qt 不在最新版本中。我尝试着将其更新到最新版本,现在 Spyder 可以工作了!现在我可以使用 Python 3.10.2 运行我的 Spyder :-)
I have glanced through the posts about the issues in Spyder and apparently, it involves upgrading or downgrading certain packages to solve the problem of running Spyder. When I look into the updatable packages in Anaconda Navigator, the PyQt and Qt are not in the latest release. I tried my luck to update it to the latest version and now the Spyder works! Now I can run my Spyder with Python 3.10.2 :-)
我解决了这个运行:
I resolved this running: