User Tools

Site Tools


python:jupyter

How to setup Jupyter Notebook on Linux

1.Installation of Python

Update packages:

sudo apt update

Install pip and Python headlines that are necessary for some dependences of Jupyter:

sudo apt install python3-pip python3-dev

2. Creating a virtual environment for Jupyter

Upgrade pip and install virtualenv:

sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv

Create working directory for virtual environment:

mkdir ~/my_project_dir
cd ~/my_project_dir

And create one for Python:

virtualenv my_project_env

To activate the created environment perform the following command:

source my_project_env/bin/activate

The command line will be changed in the similar way:

(my_project_env)user@host:~/my_project_dir$

Now you can install Jupyter Notebook into the created environment.

3. Installation of Jupyter

pip install jupyter

4. Running Jupyter Notebook

To run Jupyter Notebook locally, perform the following command:

jupyter notebook
[I 19:24:18.684 NotebookApp] Serving notebooks from local directory: /home/anton/jupyter
[I 19:24:18.684 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 19:24:18.684 NotebookApp] http://localhost:8888/?token=d79281bdf456400beaf6bbc9f089e334fb0312aa1210219f
[I 19:24:18.684 NotebookApp]  or http://127.0.0.1:8888/?token=d79281bdf456400beaf6bbc9f089e334fb0312aa1210219f
[I 19:24:18.684 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:24:18.730 NotebookApp] 

You will see the opened Notebook in your browser:

5. Stop working with Jupyter

Stop Jupyter Notebook process:

Press CTRL+C in a terminal, choose Y and press Enter to approve. You will see the following in the terminal:

[C 19:27:01.913 NotebookApp] Shutdown confirmed
[I 19:27:01.914 NotebookApp] Shutting down 0 kernels

Deactivate the virtual environment:

deactivate
python/jupyter.txt · Last modified: 2023/02/07 20:17 by a.boev

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki