Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the version of jupyter notebook from within the notebook

I wish to return the version of Jupyter Notebook from within a cell of a notebook.

For example, to get the python version, I run:

from platform import python_version
python_version()

or to get the pandas version:

pd.__version__

I have tried:

notebook.version()
ipython.version()
jupyter.version()

and several other, related forms (including capitalizing the first letters), but get errors that (for example):

NameError: name 'jupyter' is not defined

I am aware of other ways (e.g. clicking on Help>About in the GUI menu; using the conda command line) but I want to automate documentation of all package versions.

If it matters, I am running v6.1.1 of Notebook in a Python 3.7.3 environment.

like image 597
CreekGeek Avatar asked Oct 12 '20 18:10

CreekGeek


People also ask

Does Jupyter Notebook have version control?

Version control, also known as source code control, is used to track changes in code and other artifacts in software development and data science work.

How do I check my pip version Jupyter Notebook?

Check pip version with pip --version .

What is the Jupyter Notebook?

The Jupyter Notebook used to be called the IPython Notebook. If you are running an older version of the IPython Notebook (version 3 or earlier) you can use the following to upgrade to the latest version of the Jupyter Notebook.

How do I upgrade to the latest Jupyter notebook version?

If you are running an older version of the IPython Notebook (version 3 or earlier) you can use the following to upgrade to the latest version of the Jupyter Notebook. See Run the Notebook for running the Jupyter Notebook. The migrating document has additional information about migrating from IPython 3 to Jupyter.

How to check TensorFlow version in Jupyter Notebook?

Google’s Colab uses the following two commands to check for TensorFlow version:import tensorflow as tf and import tensorflow as t to check your TensorFlow version in your Jupyter Notebook such as Google’s Colab, use the following two commands:import tensorflow as print (tf. (a) This prints the version number for TensorFlow installed in X format.

How do I run Jupyter notebook with Pip?

If you already have pip installed, upgrade it to the latest version by running the following command: Logout & login again and open the terminal.Run the following command to start Jupyter Notebook: Copy one of two the URLs highlighted as shown above and open it in a browser window.


2 Answers

Paste the following command into your jupyter cell(exclamation symbol means that you need to run shell command, not python)

!jupyter --version

example output:

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

To get the python version use the python --version command:

!python --version

example output:

Python 3.6.8

UPDATE: to get values as dict you can use the following script(not perfect, written in 3 minutes)

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]

Value of parsed_versions variable

{
    "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"
}

UPDATE 2: Thanks to @TrentonMcKinney for suggestions on how to make this script better

like image 130
n0nvme Avatar answered Oct 23 '22 00:10

n0nvme


if you only need to know jupyter lab version from python code, this should work :

import jupyterlab
print(jupyterlab.__version__)
like image 41
Selmen Avatar answered Oct 23 '22 00:10

Selmen