参考centos安装pip失败
首先安装
yum -y install epel-release python-pip
然后在安装
yum -y install python-pip
遇到问题
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
You are using pip version 8.1.2, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@localhost ~]# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
7% |██▎ | 92kB 3.9kB/s eta 0:05:12Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/
。。。。
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 242, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
You are using pip version 8.1.2, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@localhost ~]#
解决方案
安装get-pip.py:
[root@localhost ~]# yum install -y wget
[root@localhost ~]# wget https://bootstrap.pypa.io/get-pip.py
[root@localhost ~]# python get-pip.py
[root@localhost ~]# pip --version
Installing Jupyter with pip
As an existing or experienced Python user, you may wish to install Jupyter using Python’s package manager, pip, instead of Anaconda.
If you have Python 3 installed (which is recommended):
python3 -m pip install --upgrade pip
python3 -m pip install jupyter
If you have Python 2 installed:
python -m pip install --upgrade pip
python -m pip install jupyter
Congratulations, you have installed Jupyter Notebook! To run the notebook, run the following command at the Terminal (Mac/Linux) or Command Prompt (Windows):
jupyter notebook
See Running the Notebook for more details.
安装ipython, jupyter
pip install ipython
pip install jupyter
jupyter notebook --generate-config
生成配置文件
[root@ ~]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
生成密码
[root@localhost ~]# ipython
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
Type "copyright", "credits" or "license" for more information.
IPython 5.8.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:b5d2f6d83bab:14ea300c104a38f388533d4f132cffb4408ccd84'
In [4]: exit
修改默认配置文件
vi /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*' #设置访问notebook的ip,*表示所有IP,这里设置ip为都可访问
c.NotebookApp.password = u'sha1:5df252f58b7f:bf65d53125bb36c085162b3780377f66d73972d1' #填写刚刚生成的密文
c.NotebookApp.open_browser = False # 禁止notebook启动时自动打开浏览器(在linux服务器一般都是ssh命令行访问,没有图形界面的。所以,启动也没啥用)
c.NotebookApp.port =8889 #指定访问的端口,默认是8888。
firewall-cmd --zone=public --add-port=8888/tcp --permanent
systemctl restart firewalld.service
systemctl stop firewalld.service
启动jupyter notebook
jupyter notebook --allow-root
[root@localhost ~]# jupyter notebook --allow-root
[W 20:43:08.883 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 20:43:08.889 NotebookApp] Serving notebooks from local directory: /root
[I 20:43:08.889 NotebookApp] The Jupyter Notebook is running at:
[I 20:43:08.889 NotebookApp] http://(localhost.localdomain or 127.0.0.1):8889/
[I 20:43:08.889 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
^C[I 20:44:19.264 NotebookApp] interrupted
在这里启动后,外网访问不了,解决办法
[root@localhost ~]# yum install -y httpd
[root@localhost ~]# systemctl start httpd.service
然后你就可以在浏览器里敲入你的地址 http://yourip:8889/
输入密码