我刚买了一台新电脑,所以我决定安装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.在错误中,它明显地表示它需要Python3.5或更高版本的,我认为它还包括我当前的3.10版本。我需要UnintasallPython3.10并安装一个旧版本吗?有什么办法可以不重新安装就解决这个问题?
另外,我不使用jupyter笔记本。
发布于 2021-10-08 18:23:49
这是由包的创建者/服务器检查错误版本造成的。
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,并且无法通过版本检查。
相关代码可以找到这里。
如果还没有bug报告,这可能会得到一个错误报告。
理想情况下,检查应该如下所示:
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)https://stackoverflow.com/questions/69500147
复制相似问题