如何在Linux系统搭建jupyter notebook

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xinxin_zhang/article/details/79816648

参考如何在Linux系统搭建jupyter notebook



准备环境,官网下载:linux版本的anaconda3:https://www.anaconda.com/download/#linux
上传到server
1.执行脚本:sudo sh Anaconda3-5.1.0-Linux-x86_64.sh
可以更换安装路径Anaconda3 will now be installed into this location:
/root/anaconda3
  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below
这里因为权限的问题,安装在/usr/lib/路径下
[/root/anaconda3] >>> /usr/lib/anaconda3
PREFIX=/usr/lib/anaconda3
installing: python-3.6.4-hc3d631a_1 ...

2.生成配置文件。
root用户:
[xx@izuf6ap06av7chyqh3bfbwz ~]$ sudo /root/anaconda3/bin/jupyter notebook --generate-config --allow-root
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
非root用户
[xx@izuf6ap06av7chyqh3bfbwz ~]$ jupyter notebook --generate-config --allow-root
Writing default config to: /home/xx/.jupyter/jupyter_notebook_config.py
[xx@izuf6ap06av7chyqh3bfbwz ~]$

3.配置环境变量到path
export PATH="/usr/lib/anaconda3/bin:$PATH"
[xx@izuf6ap06av7chyqh3bfbwz ~]$ sudo vim /etc/profile
export PATH="/usr/lib/anaconda3/bin:$PATH"
[xx@izuf6ap06av7chyqh3bfbwz ~]$source /etc/profile


4.安装jupyter的相关插件:
先执行pip install jupyter_contrib_nbextensions
出现问题:
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
upgrde : pip install --upgrade pip'
[xx@izuf6ap06av7chyqh3bfbwz ~]$ pip install --upgrade pip'
[xx@izuf6ap06av7chyqh3bfbwz ~]$ sudo pip install jupyter_contrib_nbextensions


再执行jupyter contrib nbextension install –user
[xx@izuf6ap06av7chyqh3bfbwz ~]$ jupyter contrib nbextension install --user
Error executing Jupyter command 'contrib': [Errno 2] No such file or directory





5.用生成密码:2018
[xx@izuf6ap06av7chyqh3bfbwz ~]$ ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 2018
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-631c0a197069> in <module>()
----> 1 2018

NameError: name '2018' is not defined

In [2]: from notebook.auth import passwd

In [3]: passwd()
Enter password:
Verify password:
Out[3]: 'sha1:7a46d435f848:4e307dd90b3bd41b19d8728652f6186b6998ab5'

9、编辑配置文件jupyter_notebook_config.py
[xx@izuf6ap06av7chyqh3bfbwz ~]$ vim sudo /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '192.168.1.35'  //阿里云服务器上面用ipconfig查出来的      
    
c.NotebookApp.port = 9527   
c.NotebookApp.open_browser = False 
c.NotebookApp.password = u'
sha1:7a46d435f848:4e307dd90b3bd41b19d8728652f6186b6998ab54' //上面生成的
c.NotebookApp.notebook_dir = u'/usr/lib/anaconda3/jupyter_dir'

[xx@izuf6ap06av7chyqh3bfbwz ~]$ cp /home/xx/.jupyter/jupyter_notebook_config.py /root/.jupyter/
cp: failed to access ‘/root/.jupyter/’: Permission denied
[xx@izuf6ap06av7chyqh3bfbwz ~]$ sudo cp /home/xx/.jupyter/jupyter_notebook_config.py /root/.jupyter/
[sudo] password for zxx:
[xx@izuf6ap06av7chyqh3bfbwz ~]$

jupyter : http://XXX.XX.XXX.XXX:9000   XXX.XX.XXX.XXX是阿里云服务器的外网ip
展开阅读全文

没有更多推荐了,返回首页