python3.6环境安装 pip环境配置_Python 环境配置——源码安装python3.6 pip3

1.系统

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.安装

系统默认安装了python2.7,这里演示安装python3.6。

1. 从python官网下载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版本 并创建软链接到 /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$

创建软链接

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:~$

版本没有问题,执行pip3 install 试试

error.jpg

问题原因:python3.6.5不支持lsb_release -a命令

解决办法:系统自带的python3.4支持该命令

修改 lsb_release 文件

kjs@42:~$ vim /usr/bin/lsb_release

将第一行的 python3 改成相应的python版本

1 #! /usr/bin/python3.4.4.4.4 -Es

2

3 # lsb_release command for Debian

4 # (C) 2005-10 Chris Lawrence

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

执行 pip3 install request 即可成功

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值