在服务器端上安装Jupyter

最近见到周围有些人使用Jupyter,网页端编程感觉挺爽。有需要的童鞋可以试着安装在服务器,谨此记录。

首先应该是需要安装一个anaconda

Anaconda安装步骤[1]

官网地址: https://www.anaconda.com/download/#linux

Anaconda3-5.3.0-Linux-x86_64.sh depends on what you download

wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh

bash Anaconda3-5.3.0-Linux-x86_64.sh -u

根据提示按ENTER

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

根据提示输入yes,同意license agreement

... ...
kerberos (krb5, non-Windows platforms)
A network authentication protocol designed to provide strong authentication
for client/server applications by using secret-key cryptography.

cryptography
A Python library which exposes cryptographic recipes and primitives.

Do you approve the license terms? [yes|no]
>>> yes

直接ENTER键,用默认的安装路径

Anaconda2 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

[/root/anaconda3] >>>

写入环境变量,直接输入yes

... ...
installing: zlib-1.2.8-3 ...
installing: anaconda-4.4.0-np112py27_0 ...
installing: conda-4.3.21-py27_0 ...
installing: conda-env-2.6.0-0 ...
Python 2.7.13 :: Continuum Analytics, Inc.
creating default environment...
installation finished.
Do you wish the installer to prepend the Anaconda2 install location
to PATH in your /root/.bashrc ? [yes|no]
[no] >>> yes

生效.bashrc文件

[root@master tmp]# source ~/.bashrc

输入python,验证环境

Python 3.6.5 |Anaconda 4.4.0 (64-bit)| (default, Apr 10 2018, 17:09:15) 
[GCC 4.4.7 20150623 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> 

但是在这里嘻哈遇到了似乎是没有配置成功的问题, 解决方案参考[2]

export PATH=~/anaconda3/bin:$PATH

需要安装jupyter,理论上安装好anaconda后就能够运行了,可以试试conda命令是否有效,未找到jupyter命令则pip安装

pip install jupyter

至此安装应该完成了,之后需要启动并且稍微配置一下下,之后有空写个一键包放在git上

配置[3]

先安装一些package+配置

pip install ipython

pip install jupyter

jupyter notebook –generate-config –allow-root

生成密码

[root@localhost ~]# ipython

Python 3.5.2 (default, Aug 4 2017, 02:13:48) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'

修改生成的配置文件,将以下几个地址修改如下,并且去掉该行前的#,使其生效
vi /root/.jupyter/jupyter_notebook_config.py 或者
vi ~/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'
c.NotebookApp.open_browser = False
c.NotebookApp.port =9999 #随便指定一个端口,使用默认8888也可以

访问jupyter notebook
现在命令行下开启服务,查看系统指定的是哪个端口,有可能是9999

jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

 之后就能用ip:9999访问了 EOF

One more thing

腾讯云进出站规则可参考,firewall设置参考

主要参考文献

在服务器端升级python并安装Jupyter
Centos7安装Anaconda
在centos7服务器上安装anaconda和jupyter notebook
跟我一起学python第二讲 开发工具Jupyter Notebook安装和远程访问设置
其他参考:

https://blog.csdn.net/lzc4869/article/details/78625233
http://www.edu-ing.cn/go.php?https://cn.aliyun.com/jiaocheng/433136.html?spm=5176.100033.2.7.3a5d8fc9ixUljg
http://www.edu-ing.cn/go.php?https://cn.aliyun.com/jiaocheng/433318.html?spm=5176.100033.2.9.3a5d8fc9ixUljg
Jupyter使用

猜你喜欢

转载自blog.csdn.net/qq_37279279/article/details/83410034