1、环境介绍
Linux: CentOS 6.7
Python: 2.7
2、安装python3.5
下载python3.5安装包:
wget –no-check-certificate https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz解压到当前目录:tar -zxvf Python-3.5.0.tgzcd Python-3.5.0./configure --prefix=/usr/local/python3.5 --enable-sharedmake & make installln -s /usr/local/python3.5/bin/python3 /usr/bin/python3
此时运行python3命令的话会报错,缺少.so文件,我们需要进行如下操作:cp -R /usr/local/python3.5/lib/* /usr/lib64/
ok!此时python3的基础环境已经安装完成!
3、安装pip3及setuptool
1、安装pip前需要前置安装setuptoolswget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26tar -zxvf setuptools-19.6.tar.gzcd setuptools-19.6python3 setup.py buildpython3 setup.py install报错:RuntimeError: Compression requires the (missing) zlib module我们需要在linux中安装zlib-devel包,进行支持。yum install zlib-devel
1
需要对python3.5进行重新编译安装。cd python3.5make & make install又是漫长的编译安装过程。重新安装setuptoolspython3 setup.py buildpython3 setup.py install2、安装pipwget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eebtar -zxvf pip-8.0.2.tar.gzcd pip-8.0.2python3 setup.py buildpython3 setup.py install如果没有意外的话,pip安装完成。
4、联网的机器pip3 下载jupyter pypi依赖包
mkdir /jupyter
cd jupyter
pip3 download jupyter
5、目标机器 pip3 install
将上一步下载的jupyter目录拷贝至目标机器的 /jupyter 目录
执行命令:
pip3 install /jupyter/jupyter-1.0.0-py2.py3-none-any.whl --no-index --find-links=/jupyter
jupyter的安装就完成了,接下来就是jupyter的配置
6、jupyter配置
安装完后即可以启动:
jupyter-notebook
如果在启动的时候提示,说明默认不建议使用root来运行,不过我们可以配置文件修改,接下来会介绍如何修改
Running as root is not recommended. Use --allow-root to bypass.
在上一次的版本中直接执行
jupyter notebook --generate-config
即可初始化配置文件来,但是新版的要加入–allow-root才行;
jupyter notebook --generate-config --allow-root
[root@jupyter ~]# ipython
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
Type "copyright", "credits" or "license" for more information. IPython 5.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details. In [1]: from notebook.auth import passwd In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:da874cad4309:4104089e5ef97c8fcbe69c2ac7d6a1071ca50a40'
修改配置文件中的IP地址、工作目录、并添加一个认证密码:
c.NotebookApp.allow_root = False
去掉注释,并修改成True即可解决root权限运行的问题。
c.NotebookApp.ip = 'localhost'
去掉注释,并把localhost改成0.0.0.0,这样就可以外部访问了,默认只有在本机可以访问的;
163 c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.notebook_dir = u''
改成如下,这样就会默认把notebook上创建的文件保存到指定目录下;需要事先创建。
c.NotebookApp.notebook_dir = u'/opt/jupyter' c.NotebookApp.password = u''
加入上面创建的密码:
c.NotebookApp.password = u'sha1:da874cad4309:4104089e5ef97c8fcbe69c2ac7d6a1071ca50a40'
保存,重新运行程序:
jupyter-notebook