简体   繁体   English

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

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

I just bought a new computer so I decided to install python.我刚买了一台新电脑,所以我决定安装 python。 I installed the last version which is 3.10.我安装的最后一个版本是 3.10。 Afterwards I decided to installed all the libraries I ussually use.之后我决定安装我通常使用的所有库。 One of my main projects require using a library called "vpython".我的一个主要项目需要使用一个名为“vpython”的库。 It was very difficult to reinstall everything, but I managed to do it.重新安装所有东西非常困难,但我设法做到了。 Once i tried importing the library, this error came up:一旦我尝试导入库,就会出现这个错误:

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.

In the error, it clearly sais it requires Python 3.5 or later which I think it also includes my current version 3.10.在错误中,它清楚地说它需要 Python 3.5或更高版本,我认为它还包括我当前的 3.10 版本。 Do I need to unintasall Python 3.10 and install an older version?我是否需要卸载 Python 3.10 并安装旧版本? There is any way to solve this without reinstalling?有没有什么办法不用重装就可以解决这个问题?

Also, im not using jupyter notebook.另外,我没有使用 jupyter notebook。

This is caused by bad version checking by the creator/s of the package.这是由包的创建者进行的错误版本检查引起的。

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() in this case is "3.10" so __p[2] < '5' will be True and fail the version check.在这种情况下, platform.python_version()"3.10"所以__p[2] < '5'将是True并且版本检查失败。

The relevant code can be found here .相关代码可以在这里找到。

This should probably get a bug report if it doesn't have one already.如果它还没有一个错误报告,这可能应该得到一个错误报告。

Ideally the check would look something like this:理想情况下,支票看起来像这样:

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)

Your suggestion worked!你的建议有效! I just wanted to add that I tried it today and it was able to run VPython on Python 3.10.我只是想补充一点,我今天试过了,它能够在 Python 3.10 上运行 VPython。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM