交互式编程 - jupyter notebook

安装

  1. 新建虚拟环境​Python虚拟环境virtualenvwrapper 安装配置​ (可选)
mkvirtualenv jupyter -p python3
  1. Pip 安装
pip3 install jupyter
  1. 启动
jupyter notebook --no-browser --port 8888

配置远程访问

  1. 生成默认配置文件
# 配置文件path为 ~/.jupyter/jupyter_notebook_config_backup.py
jupyter notebook --generate-config
  1. 设置密码
  • 方法1
jupyter notebook password
Enter password: #键入密码,不显示的
Verify password:            #再次重复键入密码
# 密码写入到~/.jupyter/jupyter_notebook_config.json 
  • 方法2
ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: '************'
  • 复制方法1文件中的password或者方法2的输出的密文字符串
  • 编辑​~/.jupyter/jupyter_notebook_config_backup.py​加入
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'***...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888  #可自行指定一个端口, 访问时使用该端口
  1. 启动
  • 后台启动,编写脚本​~/cmd/jupyter.sh​
cd /home/user_name
[python_path]/bin/jupyter notebook > jupyter.log  2>&1 &
  • 加入别名配置​~/.bash_profile​
alias jupyter="bash ~/cmd/jupyter.sh"
  • 生效别名配置
source ~/.bash_profile
  • 后台启动
jupyter
  • Kill
lsof -i:8888
kill  -9 [pid]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。