例外:非笔记本版本的 vpython 需要 Python 3.5 或更高版本

Exception: The non-notebook version of vpython requires Python 3.5 or later

我刚买了一台新电脑,所以我决定安装 python。我安装了最后一个版本 3.10。之后我决定安装所有我通常使用的库。我的一个主要项目需要使用一个名为“vpython”的库。重新安装所有东西非常困难,但我设法做到了。一旦我尝试导入库,就出现了这个错误:

Exception: The non-notebook version of vpython requires Python 3.5 or later.
vpython does work on Python 2.7 and 3.4 in the Jupyter notebook environment.

在错误中,它明确表示它需要 Python 3.5 或更高版本 ,我认为它还包括我当前的版本 3.10。我是否需要卸载 Python 3.10 并安装旧版本?有什么不用重装就可以解决的方法吗?

此外,我没有使用 jupyter notebook。

这是由于软件包 creator/s 的错误版本检查造成的。

import platform
__p = platform.python_version()

# Delete platform now that we are done with it
del platform

__ispython3 = (__p[0] == '3')
__require_notebook = (not __ispython3) or (__p[2] < '5') # Python 2.7 or 3.4 require Jupyter notebook

if __require_notebook and (not _isnotebook):
        s = "The non-notebook version of vpython requires Python 3.5 or later."
        s += "\nvpython does work on Python 2.7 and 3.4 in the Jupyter notebook environment."
        raise Exception(s)

platform.python_version() 在这种情况下是 "3.10" 所以 __p[2] < '5' 将是 True 并且版本检查失败。

可以找到相关代码here

如果还没有错误报告,这应该会得到一份错误报告。

理想情况下,支票应该是这样的:

import sys
__p = sys.version_info

# Delete sys now that we are done with it
del sys

__ispython3 = (__p.major == 3)
__require_notebook = (not __ispython3) or (__p.minor < 5) # Python 2.7 or 3.4 require Jupyter notebook

if __require_notebook and (not _isnotebook):
        s = "The non-notebook version of vpython requires Python 3.5 or later."
        s += "\nvpython does work on Python 2.7 and 3.4 in the Jupyter notebook environment."
        raise Exception(s)