在Centos7中安装Python 3.6.3(不删除系统自带的2.7.5)

这篇博客详细记录了如何在Centos7环境中安装Python 3.6.3,同时保留系统默认的Python 2.7.5。通过使用yum utilities安装IUS repository,然后安装python36u及其依赖,最后安装pip3.6并展示其基本用法。
部署运行你感兴趣的模型镜像

[vagrant@localhost ~]$ sudo yum install yum-utils

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.ustc.edu.cn

 * extras: mirrors.shuosc.org

 * updates: mirrors.shuosc.org

Package yum-utils-1.1.31-42.el7.noarch already installed and latest version

Nothing to do


[vagrant@localhost ~]$ sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm

Loaded plugins: fastestmirror

ius-release.rpm                                                                                                                                             | 8.1 kB  00:00:00     

Examining /var/tmp/yum-root-bgDYJp/ius-release.rpm: ius-release-1.0-15.ius.centos7.noarch

Marking /var/tmp/yum-root-bgDYJp/ius-release.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package ius-release.noarch 0:1.0-15.ius.centos7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===================================================================================================================================================================================

 Package                                   Arch                                 Version                                           Repository                                  Size

===================================================================================================================================================================================

Installing:

 ius-release                               noarch                               1.0-15.ius.centos7                                /ius-release                               8.5 k


Transaction Summary

===================================================================================================================================================================================

Install  1 Package


Total size: 8.5 k

Installed size: 8.5 k

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : ius-release-1.0-15.ius.centos7.noarch                                                                                                                           1/1 

  Verifying  : ius-release-1.0-15.ius.centos7.noarch                                                                                                                           1/1 


Installed:

  ius-release.noarch 0:1.0-15.ius.centos7                                                                                                                                          


Complete!


[vagrant@localhost ~]$ sudo yum install python36u

Loaded plugins: fastestmirror

ius                                                                                                                                                         | 2.3 kB  00:00:00     

ius/x86_64/primary_db                                                                                                                                       | 234 kB  00:00:00     

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.ustc.edu.cn

 * extras: mirrors.shuosc.org

 * ius: mirrors.tuna.tsinghua.edu.cn

 * updates: mirrors.shuosc.org

Resolving Dependencies

--> Running transaction check

---> Package python36u.x86_64 0:3.6.3-1.ius.centos7 will be installed

--> Processing Dependency: python36u-libs(x86-64) = 3.6.3-1.ius.centos7 for package: python36u-3.6.3-1.ius.centos7.x86_64

--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python36u-3.6.3-1.ius.centos7.x86_64

--> Running transaction check

---> Package python36u-libs.x86_64 0:3.6.3-1.ius.centos7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===================================================================================================================================================================================

 Package                                       Arch                                  Version                                              Repository                          Size

===================================================================================================================================================================================

Installing:

 python36u                                     x86_64                                3.6.3-1.ius.centos7                                  ius                                 56 k

Installing for dependencies:

 python36u-libs                                x86_64                                3.6.3-1.ius.centos7                                  ius                                8.7 M


Transaction Summary

===================================================================================================================================================================================

Install  1 Package (+1 Dependent package)


Total download size: 8.7 M

Installed size: 39 M

Is this ok [y/d/N]: y

Downloading packages:

warning: /var/cache/yum/x86_64/7/ius/packages/python36u-3.6.3-1.ius.centos7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 9cd4953f: NOKEY

Public key for python36u-3.6.3-1.ius.centos7.x86_64.rpm is not installed

(1/2): python36u-3.6.3-1.ius.centos7.x86_64.rpm                                                                                                             |  56 kB  00:00:00     

(2/2): python36u-libs-3.6.3-1.ius.centos7.x86_64.rpm                                                                                                        | 8.7 MB  00:00:18     

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                              492 kB/s | 8.7 MB  00:00:18     

Retrieving key from file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

Importing GPG key 0x9CD4953F:

 Userid     : "IUS Community Project <coredev@iuscommunity.org>"

 Fingerprint: 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953f

 Package    : ius-release-1.0-15.ius.centos7.noarch (installed)

 From       : /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

Is this ok [y/N]: y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : python36u-3.6.3-1.ius.centos7.x86_64                                                                                                                            1/2 

  Installing : python36u-libs-3.6.3-1.ius.centos7.x86_64                                                                                                                       2/2 

  Verifying  : python36u-libs-3.6.3-1.ius.centos7.x86_64                                                                                                                       1/2 

  Verifying  : python36u-3.6.3-1.ius.centos7.x86_64                                                                                                                            2/2 


Installed:

  python36u.x86_64 0:3.6.3-1.ius.centos7                                                                                                                                           


Dependency Installed:

  python36u-libs.x86_64 0:3.6.3-1.ius.centos7                                                                                                                                      


Complete!


[vagrant@localhost ~]$ python3.6 -V

Python 3.6.3


再安装3.6对应的pip


[vagrant@localhost ~]$ sudo yum install python36u-pip

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * epel: mirrors.ustc.edu.cn

 * extras: mirrors.shuosc.org

 * ius: mirrors.tuna.tsinghua.edu.cn

 * updates: mirrors.shuosc.org

Resolving Dependencies

--> Running transaction check

---> Package python36u-pip.noarch 0:9.0.1-1.ius.centos7 will be installed

--> Processing Dependency: python36u-setuptools for package: python36u-pip-9.0.1-1.ius.centos7.noarch

--> Running transaction check

---> Package python36u-setuptools.noarch 0:33.1.1-1.ius.centos7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===================================================================================================================================================================================

 Package                                           Arch                                Version                                              Repository                        Size

===================================================================================================================================================================================

Installing:

 python36u-pip                                     noarch                              9.0.1-1.ius.centos7                                  ius                              1.8 M

Installing for dependencies:

 python36u-setuptools                              noarch                              33.1.1-1.ius.centos7                                 ius                              648 k


Transaction Summary

===================================================================================================================================================================================

Install  1 Package (+1 Dependent package)


Total download size: 2.4 M

Installed size: 12 M

Is this ok [y/d/N]: y

Downloading packages:

(1/2): python36u-pip-9.0.1-1.ius.centos7.noarch.rpm                                                                                                         | 1.8 MB  00:00:01     

(2/2): python36u-setuptools-33.1.1-1.ius.centos7.noarch.rpm                                                                                                 | 648 kB  00:00:01     

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                              1.3 MB/s | 2.4 MB  00:00:01     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : python36u-setuptools-33.1.1-1.ius.centos7.noarch                                                                                                                1/2 

  Installing : python36u-pip-9.0.1-1.ius.centos7.noarch                                                                                                                        2/2 

  Verifying  : python36u-setuptools-33.1.1-1.ius.centos7.noarch                                                                                                                1/2 

  Verifying  : python36u-pip-9.0.1-1.ius.centos7.noarch                                                                                                                        2/2 


Installed:

  python36u-pip.noarch 0:9.0.1-1.ius.centos7                                                                                                                                       


Dependency Installed:

  python36u-setuptools.noarch 0:33.1.1-1.ius.centos7                                                                                                                               


Complete!

[vagrant@localhost ~]$ pip3.6


Usage:   

  pip <command> [options]


Commands:

  install                     Install packages.

  download                    Download packages.

  uninstall                   Uninstall packages.

  freeze                      Output installed packages in requirements format.

  list                        List installed packages.

  show                        Show information about installed packages.

  check                       Verify installed packages have compatible dependencies.

  search                      Search PyPI for packages.

  wheel                       Build wheels from your requirements.

  hash                        Compute hashes of package archives.

  completion                  A helper command used for command completion.

  help                        Show help for commands.


General Options:

  -h, --help                  Show help.

  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.

  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.

  -V, --version               Show version and exit.

  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).

  --log <path>                Path to a verbose appending log.

  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.

  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).

  --timeout <sec>             Set the socket timeout (default 15 seconds).

  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.

  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.

  --cert <path>               Path to alternate CA bundle.

  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.

  --cache-dir <dir>           Store the cache data in <dir>.

  --no-cache-dir              Disable the cache.

  --disable-pip-version-check

                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.





您可能感兴趣的与本文相关的镜像

Python3.9

Python3.9

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值