jupyter 服务器安装随笔

python3:
python3 -m pip install --upgrade pip python3 -m pip install jupyter
pkg install py36-pyzmq-18.0.1
freeBSD需要安装py*-sqlite3、需要安装py*-pyzmq
 jupyter notebook --generate-config
 jupyter lab --generate-config

jupyter server --generate-config

  该命令会在用户目录下创建一个配置目录.jupyter目录里会看到一个jupyter_notebook_config.py or jupyter_lab_config.py

主要的配置项:
  
# 登录密码,默认没有密码,所以每次启动服务器后都会产生一个随机数token,配置了密码后就不用每次使用随机数token了
c.NotebookApp.password = ''"(此处密码并非明文密码)
#开启远程登录
c.NotebookApp.ip='0.0.0.0'#notebook版本低于5.8则用*代替0.0.0.0
# 服务的端口,用默认的8888即可 
c.NotebookApp.port = 8888
# 是否需要自动弹出浏览器,服务器端一般不需要
c.NotebookApp.open_browser = False ## The directory to use for notebooks and kernels.
# 不设置的话就是启动命令所在的目录
c.NotebookApp.notebook_dir = '/home/find/work'#jupyter lab 指定运行目录后不用添加
#设置密码
c.NotebookApp.password='sha1:XXXXXXX'
#隐藏退出按钮
c.NotebookApp.quit_button=False

jupyter lab --no-browser#服务端禁用浏览器

密码生成

jupyter lab password

或者:

c.NotebookApp.password配置的并非明文密码,按照配置文件上的注释步骤生成:

  1. 在命令行下输入ipython,进入REPL环境
  2. 执行:from notebook.auth import passwd;passwd()
  3. 根据提示输入明文密码
  4. 生成hash后的密码类似如下:
In [2]: from notebook.auth import passwd; passwd()
Enter password:
Verify password:
Out[2]: 'sha1:e4ac9ea2e432:ce17c208cac9c15c59dd6f34ffe2a262f6d65bf3'

将sha1开头的一串字符,拷贝到c.NotebookApp.password字段即可。这样再次启动jupyter时,就有了密码输入界面。

 

jupyterlab安装与notebook安装时更改配置文件设置密码等都相同,区别代码如下:

pip install jupyterlab

pkg install node npm -y

查看已安装插件:jupyter labextension list

更新已安装插件:jupyter labextension update --all

 jupyter labextension install @jupyterlab/toc

jupyter labextension install @ryantam626/jupyterlab_code_formatter  #--no-build参数可不编译等待统一编译#jupyter lab build  #(jupyter lab build  --minimize=False)
pip install jupyterlab_code_formatter ;jupyter serverextension enable --py jupyterlab_code_formatter

启动
jupyter server
或者jupyter lab

修复pip
curl https://bootstrap.pypa.io/get-pip.py | python3

freebsd install lxml
pkg install libxslt
pkg install libxml2 py*-libxml2
pip install lxml

#install jupyter-lsp
pip install jupyter-lsp
jupyter labextension install @krassowski/jupyterlab-lsp
jupyter lab build --minimize=False#在jupyter lab build 错误时可用

jupyter lab拼写检查

pip install jupyterlab-spellchecker

jupyter lab代码格式化 

# Install the formatters
 $ pip install black isort
 # Install the extension
 $ pip install jupyterlab-code-formatter

 

jupyter lab代码补全,默认设置是没有打开的

1. 打开Anaconda Prompt


输出下行代码生成 .ipython 配置文件


ipython profile create 

2. 在当前用户 ~/.ipython/profile_default/下打开生成的文件


在这里插入图片描述


c.Completer.jedi_compute_type_timeout = 400
c.Completer.greedy = True
c.Completer.use_jedi = True

修改以上内容 ,注意取消注释。


重新打开jupyter lab / jupyter notebook就可以了

 

启动jupyter lab 错误:attributeerror: ‘extensionmanager‘ object has no attribute ‘_extensions‘

解决办法:pip install nbclassic==0.2.8

posted @ 2019-05-07 13:34  defifind  阅读(1504)  评论(0编辑  收藏  举报