Centos7 安装python3

来自CloudWiki
Cloud17讨论 | 贡献2019年7月10日 (三) 08:45的版本 (创建页面,内容为“===python3的安装=== 一、首先,官网下载python3的所需版本。 wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz 想下载到那个文件…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

python3的安装

一、首先,官网下载python3的所需版本。

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

想下载到那个文件夹下就先进入到那个文件夹下——cd /home/download

二、然后,解压缩文件》

tar -xvf Python-3.6.0.tgz

三、创建安装文件的路径。

mkdir /usr/local/python3

四、编译。

cd Python-3.6.0
./configure --prefix=/usr/local/python3

五、安装。

1、make

2、make install

3、完毕

六、创建新版本的软连接。

0.查看旧版本Python解释器的入口

which python

输出为:

/usr/bin/python

1、修改旧版本

mv /usr/bin/python /usr/bin/python_bak

2、创建新的软连接

ln -s /usr/local/python3/bin/python3 /usr/bin/python

3、检查python的版本

python -V

python-3.6.0

软连接创建成功

pip3的安装

1. 下载安装zlib模块

$wget http://www.zlib.net/zlib-1.2.11.tar.gz
$tar -xvzf zlib-1.2.11.tar.gz
$./configure
$make
$make install

2.重新编译安装python

$cd Python-3.6.0
$./configure --prefix=/usr/local/python3
$make
$make install

3. 这时pip3自动安装到了系统中

[root@iZwz9c7pkk6xpht2857qkhZ ~]# pip3

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


参考文档

[linux下配置安装python3 https://www.cnblogs.com/Guido-admirers/p/6259410.html ]

[解决python3缺少zlib的问题 https://www.cnblogs.com/galaxy-gao/p/5796488.html]