将以下命令粘贴到您的 jupyter 单元格中(感叹号表示您需要运行 shell 命令,而不是 python)
!jupyter --version
示例输出:
jupyter core : 4.6.0
jupyter-notebook : 6.0.1
qtconsole : 4.7.5
ipython : 7.8.0
ipykernel : 5.1.3
jupyter client : 5.3.4
jupyter lab : not installed
nbconvert : 5.6.0
ipywidgets : 7.5.1
nbformat : 4.4.0
traitlets : 4.3.3
要获取 python 版本,请使用python --version
命令:
!python --version
示例输出:
Python 3.6.8
UPDATE:要获取 dict 形式的值,您可以使用以下脚本(不完美,仅用 3 分钟编写)
import subprocess
versions = subprocess.check_output(["jupyter", "--version"]).decode().split('\n')
parsed_versions = {}
for component in versions:
if component == "":
continue
comps = list(map(str.strip, component.split(': ')))
parsed_versions[comps[0]] = comps[1]
的价值parsed_versions
多变的
{
"jupyter core": "4.6.0",
"jupyter-notebook": "6.0.1",
"qtconsole": "4.7.5",
"ipython": "7.8.0",
"ipykernel": "5.1.3",
"jupyter client": "5.3.4",
"jupyter lab": "not installed",
"nbconvert": "5.6.0",
"ipywidgets": "7.5.1",
"nbformat": "4.4.0",
"traitlets": "4.3.3"
}
更新2:感谢@TrentonMcKinney 提供有关如何改进此脚本的建议