阿里云服务器安装配置jupyter

阿里云服务器安装jupyter

1、安装jupyter

这里网上一些文章大部分都需要先安装Anaconda或virtualenv虚拟环境,但我为了简便直接用pip3装jupyter;这里最好用pip3安装,如果你有python2和python3的环境的话就都可以使用

pip3 install jupyter

2、生成配置文件需要的密码

使用ipython交互界面输入:

from notebook.auth import passwd

passwd()

3、生成并修改配置文件

jupyter notebook --generate-config
vim ~/.jupyter/jupyter_notebook_config.py

修改参数:

c.NotebookApp.ip='0.0.0.0'                             # 设置所有ip都可以访问
c.NotebookApp.password = u'sha:80...'                # 之前得到的密文密码
c.NotebookApp.open_browser = False                   #  禁止自动打开浏览器
c.NotebookApp.port =8889                           # 服务启动的端口,可自由设置,此时设置是8889

这里也可以加一句c.NotebookApp.allow_root = True 这样在启动时就不用加--allow-root选项了

4、启动jupyter notebook

jupyter notebook

为了我们退出终端后它还能生效,我们要保持这个服务后台启动。

nohup jupyter notebook --allow-root &

5、远程访问

因为我们搭在服务器上就是为了远程访问,所以需要在阿里云服务器控制台的防火墙规则里添加一条允许所有ip访问8889端口的规则,这样就可以使用我们的域名或公网ip加8889端口访问jupyter了

6、杂项记录

1、debian安装pip3
apt install python3-pip
验证:pip3 -v

2、卸载jupyter
pip freeze 查看所有jupyter包
pip uninstall jupyter包 -y

猜你喜欢

转载自www.cnblogs.com/zw1sh/p/13181334.html