In ubuntu, jupyter notebook starts automatically in the background, and in anaconda, jupyter notebook starts automatically.

1. First of all, we all know that most ubuntu startup files are suffixed with .sh

2. So choose a path and create a file with the suffix .sh as the startup file of the notebook

Here I choose the path to create a file named start-jupyter.sh under /home/hadoop/anaconda3/sbin

 3. Edit start-jupyter.sh, command vim ./start-jupyter.sh, the content is as follows:

source activate tensorflow
jupyter notebook --ip 192.168.74.128 --port 8889 /home/hadoop --allow-root

Here is a special explanation:

  • source activate tensorflow is to activate the anaconda environment I created before. My environment is called tensorflow, so change tensorflow to your environment name. If you don’t have anaconda installed, you don’t need to write this statement, just write the second one directly.
  • The second statement is to start jupyter notebook and fill in your own IP address. The default port is 8889. If the port is changed, fill in the change. /home/hadoop is the path content displayed when the web page is opened
  • save and exit

4. After editing the file, start to set this file to start automatically after booting

  • Enter the local user directory autostart
  • Enter the command cd ~/.config/autostart
  • Then create a new file with the suffix .desktop, and then edit the file with vim, the content is for example:
  • [Desktop Entry]
    Type=Application #类型是应用程序
    Exec=/home/hadoop/anaconda3/sbin/start-jupyter.sh #输入你要自启动的.sh文件的绝对路径
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[en_US]=jupyter #名字(任意写)
    Name=jupyter #名字(任意写)
    Comment[en_US]=notebook #任意写
    Comment=notebook #任意写
    
  • Remember to remove the comments in my content when copying and pasting
  • Finally, restart the login page to see if the jupyter notebook is started successfully!

Guess you like

Origin blog.csdn.net/m0_59799878/article/details/127092167