This article was originally published on Jupyter on Remote Access Linux.

Because of the poor network environment of the lab, every time I use Conda to open a new environment and download some new packages, it will be very slow, WHICH I can tolerate. The problem is that I often fail to download, which wastes my time. Then I think I have a server of Tencent Cloud. I just want to download Jupyter from the server and access it remotely.

Download Miniconda

First you need to download Miniconda. I didn’t download Anaconda because I didn’t need that many packages

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Copy the code

If you do not have the wget command, you can use yum -y install wget to download it.

Here is a shell script that you can run to automatically download Miniconda

chmod +x Miniconda3-latest-Linux-x86_64.sh # Add executable permission
./Miniconda3-latest-Linux-x86_64.sh        # Execute script
Copy the code

Some questions will be asked during the download. Just answer yes.

After the installation is complete, enter the command line again and type

conda -V
Copy the code

If the version number is printed correctly, the download is successful.

Download jupyter

So let’s create a new environment, let’s call it jupyter

conda create -n jupyter
Copy the code

And then activate the environment

conda activate jupyter
Copy the code

Then download Jupyter

conda install jupyter
Copy the code

Configure a password

To access Jupyter remotely, we need to configure a password to log in, and enter ipython on the command line (which was already downloaded when we downloaded Jupyter) to enter a Python interactive shell

ipython
Copy the code

Enter the following commands in turn

from notebook.auth import passwd
passwd()
Copy the code

You will then be prompted for a password, which will give you a ciphertext string such as

'sha1:43b95b731276:5d330ee6f6054613b3ab4cc59c5048ff7c70f549'
Copy the code

This ciphertext string will be used in jupyter’s configuration file, save/copy it first.

Jupyter configuration file

Next we need to configure jupyter’s configuration file and run it on the command line

jupyter notebook --generate-config
Copy the code

The ~/.jupyter/jupyter_notebook_config.py file will be generated and we will open it and edit it

vi ~/.jupyter/jupyter_notebook_config.py
Copy the code

Add the following configuration to it

c.NotebookApp.ip=The '*' Set the IP address for remote access to Jupyter. * indicates that all IP addresses can be accessed
c.NotebookApp.allow_remote_access = True Allow remote access
c.NotebookApp.password = 'sha1:5df252f58b7f:bf65d53125bb36c085162b3780377f66d73972d1' # Fill in the generated ciphertext
c.NotebookApp.open_browser = False Disable the Notebook from automatically opening the browser when it starts. So, it doesn't work.)
c.NotebookApp.port =8888 # Specifies the port to access. Default is 8888
Copy the code

Start the jupyter

Now we can start jupyter by typing the following command on the command line

jupyter notebook --allow-root
Copy the code

This command runs in the foreground when started, if we want jupyter to run in the background, we can run the following command

nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
Copy the code

We can access the Jupyter Notebook through the server’s public IP address :8888.

PS: If you want to stop Juputer on the server, run it first

ps
Copy the code

This command can display the processes that are running, we find the PID of the jupyter process and then pass

kill -9 pid
Copy the code

To kill the Jupyter service and stop jupyter.

Refer to the link

  • Install Miniconda on Linux
  • Configure remote access for the Jupyter Notebook on Linux
  • How to let Jupyter run in the background in the cloud Server (3)