惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
C
Check Point Blog
博客园_首页
B
Blog
D
Docker
U
Unit 42
量子位
I
InfoQ
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
GbyAI
GbyAI
L
LangChain Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
美团技术团队
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
Vercel News
Vercel News
Recent Announcements
Recent Announcements
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Google DeepMind News
Google DeepMind News

博客园 - 路缘

安装discourse 【转】ASP.NET Core 搭配 Nginx 的真实IP问题 【转】ASP.NET Core Module C++生成错误 windows 命令 【转】什么是5G?居然有人用漫画把它讲得如此接地气! 【转】Centos下编译升级安装Boost 【转】SSH穿越跳板机:一条命令跨越跳板机直接登陆远程计算机 部署JupyterLab和pyalgotrade搭建web策略回测环境 环境命令备忘 [转]微软商店 打开就显示无法加载该页面 代码0x80131500? [转]Centos 7 安装部署 GitLab 服务器 [转]本文采用all-in-one(一体化的)安装OpenShift [转]Linux编译和安装boost库 vn.trader的Ubuntu运行环境搭建教程 [转]vnpy乱乱谈 02架构 【转】Docker简介与入门 【转】linux scp远程拷贝文件及文件夹 [转]OpenShift 集群搭建指南
[转]Linux中python3.6+ipython+Jupyter Notebook环境
路缘 · 2019-03-22 · via 博客园 - 路缘

Posted on 2019-03-22 16:45  路缘  阅读(1029)  评论()    收藏  举报

python3.6安装


  1. 下载python安装包,这里下载的最新的3.6.1版本
    https://www.python.org/ftp/python/3.6.1/
  2. 将安装包上传到服务器并解压
tar zxvf Python-3.6.1.tgz
  1. 安装python
cd Python-3.6.1
./configure --prefix=/usr/local/python-3.6.1     #重要,指定python的安装路径,可以自己设置。
make
sudo make install
  1. 修改python的软链接 (建立软链接,变为全局)
sudo ln -s /usr/local/python-3.6.1/bin/python3.6 /usr/bin/python
  1. 查看python版本,发现已经改变
    python

ipython安装


  1. 下载ipython,并上传到服务器
    http://archive.ipython.org/release/6.0.0/
  2. 解压
tar -zxvf ipython-6.0.0.tar.gz
  1. 进入解压的ipython目录并执行如下命令进行安装
python setup.py install
  1. 进行链接
ln -s /usr/local/python-3.6.1/bin/ipython /usr/sbin/ipython
  1. 检查ipython是否安装成功
ipython

此时发现提示说有模板缺失,使用pip进行安装。

pip install traitlets

再执行ipython进行检验,发现还是某个模板缺失


继续用pip进行安装,知道执行ipython时出现如下界面,代表安装成功。


Jupyter Notebook安装


Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。Notebook是一个数据分析和编写代码的好工具。它的核心在于展示与快速迭代。
摘自: 知乎为什么使用jupyter?
看完知乎的这个回答会对jupyter有个大概的认知,接下来进行安装。

  1. 安装jupyter notebook
pip install jupyter notebook 
  1. 启动notebook
jupyter notebook

此时报错,不建议用root运行启动命令:

[I 16:23:40.195 NotebookApp] Writing notebook server cookie secret to /root/.local/t
[C 16:23:40.213 NotebookApp] Running as root is not recommended. Use --allow-root t.

解决方法:

  • 修改配置文件,执行jupyter notebook --generate-config即可初始化配置文件来,但是这里要加入--allow-root才行
[root@localhost ~]# jupyter notebook --generate-config --allow-root
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
  • 创建一个密码:[这样就不用每次复制URL地址]
[root@localhost ~]# ipython
Python 3.6.1 (default, May 25 2017, 16:49:43) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.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:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'

将这里的 ```
'sha1:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'

 *  修改配置文件中的IP地址、工作目录、并添加一个认证密码:

[root@localhost .jupyter]# vim /root/.jupyter/jupyter_notebook_config.py

修改权限

c.NotebookApp.allow_root = False

去掉行注释,并修改成True即可解决root权限运行的问题。

设置,外部可访问

c.NotebookApp.ip = 'localhost'

去掉注释,并把localhost改成0.0.0.0,这样就可以外部访问了,默认只有在本机可以访问的;
c.NotebookApp.ip = '0.0.0.0'

设置notebook的工作目录

c.NotebookApp.notebook_dir = u''

改成如下,这样就会默认把notebook上创建的文件保存到指定目录下;需要事先创建。
c.NotebookApp.notebook_dir = u'/opt/jupyter'

加入密码

c.NotebookApp.password = u''

加入上面创建的密码:
c.NotebookApp.password = u'sha1:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'

3. 进入notebook界面
再次执行启动命令,出现如下信息,表示成功

[root@localhost .jupyter]# jupyter-notebook
[I 18:09:58.194 NotebookApp] Serving notebooks from local directory: /opt/jupyter
[I 18:09:58.194 NotebookApp] 0 active kernels
[I 18:09:58.194 NotebookApp] The Jupyter Notebook is running at:
http://0.0.0.0:8888/bookApp]

在浏览器输入如下网址:http://你的ip:8888
可以看到如下界面:
![](http://upload-images.jianshu.io/upload_images/3832654-94a8ebba9ef56652.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

**参考:**
[官方文档](https://jupyter.readthedocs.io/en/latest/install.html)
[centos7安装notebook 5.0.0的方法](https:

作者:夏无忧阳
链接:https://www.jianshu.com/p/0133f79a12db
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

vim /etc/systemd/system/***.service

systemctl daemon-reload

systemctl status *** -l

systemctl start ***