x# 在线安装 jupyter, 在线安装有一部分包的版本不兼容,一般使用低版本的包能解决pip install jupyter# 离线安装pip3 install --no-index --find-links=. -r requirements.txtpip2 install --no-index --find-links=. -r requirements.txt
xxxxxxxxxx# 生成配置jupyter notebook --generate-config# Windows 在 %USERPROFILE%\.jupyter\jupyter_notebook_config.py# Linux 在 ~/.jupyter/jupyter_notebook_config.pyc.NotebookApp.allow_root = Truec.NotebookApp.base_project_url = '/toolclis'c.NotebookApp.notebook_dir = '/jupyter_notebook/'c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
xjupyter notebookpython2 -m jupyter notebookpython3 -m jupyter notebook# linux默认不允许root运行jupyter notebook# [C 16:38:27.845 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.# linux 创建jupyter用户运行,允许外网访问useradd jupytersu - jupytermkdir jupyter_notebook# 前台运行 # windowsjupyter notebook --notebook-dir=./jupyter_notebook/ --ip=0.0.0.0# 后台运行nohup jupyter notebook --notebook-dir=./jupyter_notebook/ --ip=0.0.0.0 &# 后台root身份运行nohup jupyter notebook --notebook-dir=./jupyter_notebook/ --allow-root --ip=0.0.0.0 &# 后台root身份运行,指定--NotebookApp.token无法修改密码nohup jupyter notebook --notebook-dir=./jupyter_notebook/ --allow-root --ip=0.0.0.0 --NotebookApp.token=${xxx} &
重置Token
xxxxxxxxxx# 手动设置Token,保存在jupyter_notebook_config.json文件中jupyter notebook password# 无缝重启kill -9 $(ps -ef | grep jupyter-notebook | grep -v grep | awk '{print $2}'); nohup jupyter notebook --notebook-dir=./jupyter_notebook/ --allow-root --ip=0.0.0.0 &
复制这三个网址其中一个到浏览器
xxxxxxxxxxTo access the notebook, open this file in a browser:file:///C:/Users/%E9%99%88%E5%85%A8%E5%BA%94/AppData/Roaming/jupyter/runtime/nbserver-8436-open.htmlOr copy and paste one of these URLs:http://localhost:8888/?token=2deffc2981725d4a808fc8e1e0689d53048bf95f2f22e04cor http://127.0.0.1:8888/?token=2deffc2981725d4a808fc8e1e0689d53048bf95f2f22e04c
xxxxxxxxxx# 查看当前在运行的jupyter[jupyter@VM-4-6-centos ~]$ jupyter notebook listCurrently running servers:http://0.0.0.0:8888/?token=3f5cc71aa2d1cda4c836df036e619ffd8b490e199171c272 :: /home/jupyter/jupyter_notebook# 查看本机已安装的 jupyter 内核版本[jupyter@VM-4-6-centos ~]$ jupyter-kernelspec listAvailable kernels:python3 /usr/local/share/jupyter/kernels/python3python2 /usr/share/jupyter/kernels/python2# python3的jupyter notebook 使用python2,需安装 python2内核,否则python2无法正常执行python2 -m ipykernel install --userpython3 -m ipykernel install --user# 查看 jupyter 内核版本[jupyter@VM-4-6-centos jupyter_notebook]$ jupyter-kernelspec listAvailable kernels:python2 /home/jupyter/.local/share/jupyter/kernels/python2python3 /home/jupyter/.local/share/jupyter/kernels/python3
菜单 - Help - Keyboard Shortcuts 可以查看快捷键。
调整 Jupyter 的 Notebook/Terminals 页面宽度,只要将以下内容放入文件 .jupyter/custom/custom.css 。
xxxxxxxxxxmkdir -p .jupyter/custom/cat > .jupyter/custom/custom.css <<EOF/* # the note book page */.notebook_app .container {width:98%; !important}/* # the terminal page */.terminal-app .container {width:98%; !important}EOF
需要重启 jupyter
xxxxxxxxxx[I 21:25:21.379 NotebookApp] Creating new notebook in Bad file descriptor (C:\projects\libzmq\src\epoll.cpp:100)
原因分析: 安装的 pyzmq 库版本过高,为 22.3.0,故我们降低版本即可,降低至 19.0.2
解决方案: pip uninstall pyzmq # 卸载当前 pyzmq pip install pyzmq==19.0.2 # 安装版本为 19.0.2 的 pyzmq
ERROR: Cannot uninstall 'ipaddress'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. ERROR: Cannot uninstall 'enum34'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. 系统自带了 低版本的 ipaddress enum34,不安装新版本即可