美文网首页
在服务器装jupyter notebook, 在本地远程。记录各

在服务器装jupyter notebook, 在本地远程。记录各

作者: winddy_akoky | 来源:发表于2019-12-11 09:58 被阅读0次

实验环境:

  1. 服务器:ubuntu 16.04
  2. 本地:win10

1. 装jupyter notebook

装jupyter notebook
1. conda install jupyter notebook

在服务器配置jupyter notebook
2. 生成配置文件:
jupyter notebook --generate-config 
(文件在/home/<用户名>/.jupyter/jupyter_notebook_config.py)
3. 生成密码:
ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:117e0cc9673e:5ca67b637e0e2180027d36f8830c5711b7cf8e2f'
4. 编辑jupyter_notebook_config.py
vim .jupyter/jupyter_notebook_config.py 

修改下面部分即可:
c.NotebookApp.ip = '*'  # 就是设置所有ip皆可访问,在144行
c.NotebookApp.open_browser = False  # 禁止自动打开浏览器
# 密钥,在194行。该密钥就是2.1步生成的
c.NotebookApp.password = 'sha1:117e0cc9673e:5ca67b637e0e2180027d36f8830c5711b7cf8e2f'
c.NotebookApp.port = 8888  # 访问端口,在197行
c.NotebookApp.allow_remote_access = True

  1. 在服务器运行Jupyter notebook, 然后本地直接连上去就行了。

报错

如果你原本啥库都没装,jupyter notebook是可以正常远程的,在装了某些库后,就报错了(连接不上内核)。比如:

1. Command "python setup.py egg_info" failed with error code 1

2. It is a distutils installed project and thus we cannot accurately determine which files belong to

3. KernelRestarter: restart failed

...等等

解决方法

有些错误的产生是由于jupyter 版本跟一些库的版本对不上,说白了就是Jupyter本身的bug,所以,升级conda和所有库基本能避免大部分问题:

1. 更新conda:
conda update conda

2. 更新conda某个环境下的所有包:
conda update --all

这时候检查jupyter notebook是不是可以正常运行。如果正常了,再指定装特定版本的库即可满足各种配置要求。

相关文章

网友评论

      本文标题:在服务器装jupyter notebook, 在本地远程。记录各

      本文链接:https://www.haomeiwen.com/subject/rhfogctx.html