centos6安装python_centos6安装Python3环境

Python3安装

CentOS 6+系统默认安装的python版本是2.6.6,python2版本与python3还有有一些语法上的不一样。我们要把python升级到3版本,但是系统自带的旧版本python被系统很多其他软件环境依赖,所以不能直接卸载原来的2版本,所以我们重新安装一个3版本,将2版本的依赖保留。

1、下载Python安装包

2、安装源码编译器等工具:

[root@bigdata-pro03 softwares]# yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel

3、解压下好的源码包:

[root@bigdata-pro03 softwares]# tar -xzvf Python-3.6.0.tgz

[root@bigdata-pro03 softwares]# cd /opt/modules/Python-3.6.0/[root@bigdata-pro03 Python-3.6.0]# ls

aclocal.m4 configure Grammar Lib Makefile.pre.inObjects PCbuild Python Tools

config.guess configure.ac Include LICENSE Misc Parser Programs README

config.sub Doc install-sh Mac Modules PC pyconfig.h.in setup.py

4、编译安装包,指定安装路径:

注意:prefix参数用于指定将Python安装在新目录,这样不会覆盖原有的python。

./configure --prefix=/usr/local/python36

make&& make install

5、修改系统默认的Python路径,因为默认的python指向2.6

mv /usr/bin/python /usr/bin/python-2.6.6

6、建立新的软连接,指向Python-3.6.0:

注:这里的python36是第4步指定的安装路径,python3.6是Python包里的可执行程序

ln -s /usr/local/python36/bin/python3.6 /usr/bin/python

7、因为yum是依赖python的,所以这里我们修改了默认的python,就要要修改yum,让其运行指向旧的版本:

vim /usr/bin/yum

将第一行“#!/usr/bin/python”

修改为“#!/usr/bin/python-2.6.6”

8、测试按是否安装成功

[root@bigdata-pro02 Python-3.6.0]# python

Python3.6.0 (default, Nov 16 2019, 09:39:23)

[GCC4.4.7 20120313 (Red Hat 4.4.7-23)] on linux

Type"help", "copyright", "credits" or "license" formore information.>>>

可以看到,已经成功安装Python3.6.0!

pip3安装

1、下载安装文件,使用python命令进行安装

wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py

python get-pip.py

2、为pip建立软连接,使用pip命令安装requests模块

ln -s /usr/local/python36/bin/pip3.6 /usr/bin/pip

pip-V

pip install requests

[root@bigdata-pro03 gcc-build-9.2.0]# pip

Usage:

pip[options]

Commands:

install Install packages.

download Download packages.

uninstall Uninstall packages.

freeze Output installed packagesinrequirements format.

list List installed packages.

show Show information about installed packages.

check Verify installed packages have compatible dependencies.

config Manage local andglobalconfiguration.

search Search PyPIforpackages.

wheel Build wheelsfromyour requirements.

hash Compute hashes of package archives.

completion A helper command usedforcommand completion.

debug Show information usefulfordebugging.

help Show helpforcommands.

General Options:-h, --help Show help.--isolated Run pip inan isolated mode, ignoring environment variables and user configuration.-v, --verbose Give more output. Option is additive, and can be used up to 3times.-V, --version Show version and exit.-q, --quiet Give less output. Option is additive, and can be used up to 3times (corresponding to WARNING, ERROR,

and CRITICAL logging levels).--log Path to a verbose appending log.--proxy Specify a proxy inthe form [user:passwd@]proxy.server:port.--retries Maximum number of retries each connection should attempt (default 5times).--timeout Set the socket timeout (default 15seconds).--exists-action Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.--trusted-host Mark this host or host:port pair astrusted, even though it does not have valid or any HTTPS.--cert Path to alternate CA bundle.--client-cert Path to SSL client certificate, a single file containing the private key and the certificate inPEM

format.--cache-dir

Don't periodically check PyPI to determine whether a new version of pip is available for download.

Implied with --no-index.--no-color Suppress colored output

到此,Centos系统下的Python3环境就搭建完成了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值