jupyter notebook相信很多人都用过,内置了很多python的包,用来机器学习非常方便。不过对于我这样的学生党,在学校的电脑上都没有现成的jupyter notebook可以用,现装又很麻烦,那么为什么不能把jupyter notebook装到vps里呢,这样只要有浏览器连手机都能跑python了。
首先自然是要安装jupyter notebook了
现在大多数vps(比如阿里云)都自带了python3(python3 --version可以查看是否安装了python3和python3版本)
官方的教程中使用的是pip安装,如果没有pip需要先安装,如果有可以直接安装
apt install python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install jupyter
jupyter中使用的是8888端口,在一些云服务器提供商那里我们可能需要允许8888端口,例如阿里云需要在网络与安全-安全组-配置规则中添加安全组,分别添加允许入方向和出方向的8888端口
安装成功后我们需要设置密码,输入以下指令后重复输入两次密码
jupyter notebook password
接下来我们就可以启动了
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root
jupyter notebook默认监听8888端口,如果8888端口已被占用(比如宝塔面板)可以更改jupyter的监听端口
jupyter notebook --port 9999
不改端口的情况下在浏览器中输入ip:8888后输入设置的密码即可访问
不过jupyter启用后一直占用前台,可以使用命令让他后台运行
nohup jupyter notebook --ip 0.0.0.0 --allow-root > jupyter.log 2>&1 &