博客园
虽然痛苦,却依旧要快乐,并相信着未来。

导航

 

jupyter 安装配置

参考文章

虽然不建议用root权限去运行pip或者jupyter,但是暂时为了方便省事,以下使用是的root权限。

# 安装
pip install jupyter notebook
# 利用python 生成jupyter 密码,
python3
    >>> from notebook.auth import passwd
    >>> passwd()
	# 输入密码后,生成字符串复制
    >>> exit()

# 生成配置文件,记住目录,下面会用到
    jupyter notebook --generate-config 
# 打开配置文件,jupyter_notebook_config.py位置会有所不同,勿直接复制
    vim /home/ubuntu/.jupyter/jupyter_notebook_config.py

# 建议修改以下内容
    c.NotebookApp.allow_remote_access = True #允许远程连接
    c.NotebookApp.ip='0.0.0.0' # 设置所有ip皆可访问
    c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$4EIqux1hNfgkFuqoWiEnUQ$k/CAr9P2J4/5GlBcsXTnJA' #之前复制的密码
    c.NotebookApp.open_browser = False # 禁止自动打开浏览器
    c.NotebookApp.port =8888 #任意指定一个端口
    c.NotebookApp.notebook_dir ='/home/ubuntu/programes/'

### 提示: vim中/是搜索,n是前进查找,N是后退查找,u是撤回操作,i是插入,dd是删除整行,x是删除单个字符

#jupyter 补全插件
#安装nbextensions
    pip install jupyter_contrib_nbextensions
    jupyter contrib nbextension install --user
#安装 nbextensions_configurator
    pip install jupyter_nbextensions_configurator
    jupyter nbextensions_configurator enable --user
#重启jupyter

# 启动操作
    jupyter notebook > jupyter.log 2>&1 &
    
# 停止jupyter
	jupyter notebook stop
# 进程杀死jupyter,一般是第一个/usr/local/bin/jupyter-notebook
	ps -ef | grep jupyter-notebook
	kill XXX
#例子:#ps -ef | grep jupyter-notebook
#root      8687     1  0 16:31 pts/1    00:00:04 /usr/bin/python /usr/local/bin/jupyter-notebook
#root      8852  8629  0 16:51 pts/1    00:00:00 grep --color=auto jupyter-notebook
#kill 8687

推荐图形化资源管理器 btop,可杀死进程。

posted on 2022-08-14 16:56  砖猿  阅读(97)  评论(0编辑  收藏  举报