1.系統(tǒng)
666@66:/proc$ cat /proc/version
Linux version 4.4.0-128-generic (buildd@lgw01-amd64-055) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4) )
2.安裝
系統(tǒng)默認安裝了python2.7音榜,這里演示安裝python3.6溃蔫。
1. 從python官網(wǎng)下載python3.6.5 Source release版本
download.png
2. 解壓源碼安裝
- 解壓得到Python-3.6.5文件夾
kjs@42:~/下載$ xz -d Python-3.6.5.tar.xz
kjs@42:~/下載$ tar -xvf Python-3.6.5.tar
- 進入文件夾空另,進行編譯(指定目標文件夾,pip 的時候可能缺少 ssl搬俊,所以這里配置的時候加上)
kjs@42:~/下載/Python-3.6.5$ ./configure --prefix=/usr/local/python-3.6 --with -ssl
- 編譯及安裝
kjs@42:~/下載/Python-3.6.5$ make
kjs@42:~/下載/Python-3.6.5$ sudo make install
3.檢查python pip版本 并創(chuàng)建軟鏈接到 /usr/bin下
- 檢查版本
kjs@42:~/下載/Python-3.6.5$ cd /usr/local/python-3.6/bin
kjs@42:/usr/local/python-3.6/bin$ ./python3
Python 3.6.5 (default, Jul 5 2018, 14:32:19)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
kjs@42:/usr/local/python-3.6/bin$ ./pip3 -V
pip 10.0.1 from /usr/local/python-3.6/lib/python3.6/site-packages/pip (python 3.6)
kjs@42:/usr/local/python-3.6/bin$
- 創(chuàng)建軟鏈接
kjs@42:/usr/local/python-3.6/bin$ sudo ln -s python3 /usr/bin/python3
kjs@42:/usr/local/python-3.6/bin$ sudo ln -s pip3 /usr/bin/pip3
- 檢查
kjs@42:~$ python3
Python 3.6.5 (default, Jul 5 2018, 14:32:19)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
kjs@42:~$ pip3 -V
pip 10.0.1 from /usr/local/python-3.6/lib/python3.6/site-packages/pip (python 3.6)
kjs@42:~$
版本沒有問題倦春,執(zhí)行pip3 install
試試
error.jpg
問題原因:python3.6.5不支持lsb_release -a命令
解決辦法:系統(tǒng)自帶的python3.4支持該命令
修改 lsb_release 文件
kjs@42:~$ vim /usr/bin/lsb_release
將第一行的 python3 改成相應(yīng)的python版本
1 #! /usr/bin/python3.4.4.4.4 -Es
2
3 # lsb_release command for Debian
4 # (C) 2005-10 Chris Lawrence <lawrencc@debian.org>
5
6 # This package is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; version 2 dated June, 1991.
9
10 # This package is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this package; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 # 02110-1301 USA
19
20 # Python3-compatible print() function
21 from __future__ import print_function
22
23 from optparse import OptionParser
執(zhí)行 pip3 install request
即可成功