Jupyter connects to the server remotely (windows/Mac = the difference is that one is in the cmd command when using the ssh command, and the other opens a new terminal window)

1. Create a new virtual environment: conda create --prefix /icislab/volume1/xxx/envs/new environment name python3.7 (specify the new path, specify the python version)

2. Activate the newly created environment: conda activate new environment name

-----There is nothing in this environment at present, you can use pip to install------

3. Install the jupyter package

pip install jupyter

4. Generate a configuration file (this step will not display anything, just run it directly without reporting an error)

jupyter notebook --generate-config


5. Open the python interactive window and set the password to enter the jupyter page
 

ipython #输入ipython后,就会出现:input[1] ,接着同时输入下面两行命令即可
from notebook.auth import passwd
passwd()

6. After setting the password, the ciphertext will be output, and the ciphertext will be modified into the configuration file later, as follows:

Ciphertext: Out[5]: 'sha1:00214b681a80:720acf7885d392f5f5407d4e7cbc73755a677dfd'7

7. Modify the configuration file:

vim ~/.jupyter/jupyter_notebook_config.py

 After entering the above command, you will enter an interface like this: (press and hold i to enter the edit mode, enter the modification to be inserted in the blank space; then press and hold the esc key to exit; then click ":" to enter below, enter wq, save and exit the configuration file.

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8889 	#本人改了下端口号,因为怕和别的端口冲突(可改可不改),这个不会影响什么,随时运行Jupyter随时可以指定端口号

8. Start jupyter

jupyter notebook --no-browser --port=8888

One of the terminal operation interface is as follows (terminal connected to the server)

9. Use the ssh command to connect the local machine and the server port number (roughly this means), anyway, three terminals need to run together: on the server, on the local command, on the browser

The other is as follows (run the local remote connection ssh command)   on the terminal page, press and hold command+N, you can open a new terminal page, enter a local command, which is equivalent to the cmd command terminal of windows

The ssh command is as follows:

ssh -L 8888:localhost:8888 [email protected] -p 22

Other commands to be used on Jupyter:

Register the virtual environment as the Jupyter kernel:

1. Activate the virtual environment to be registered as the kernel

conda activate 环境名

2. Install the ipykernel package

pip install ipykernel
3. Register the virtual environment as a Jupyter kernel:
python -m ipykernel install --user --name=scipennenv

After performing the above steps, restart Jupyter Notebook and you should be able to see the registered virtual environment as an available option in the kernel list

Guess you like

Origin blog.csdn.net/m0_73524607/article/details/131657072