linux python3安装包_在 Linux 中安装 Python3

系统环境:CentOS 6.8

找到源码包后可以拷贝下载链接,在 Linux 中直接使用 wget 命令下载:

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

下载后解压:

tar -xJf Python-3.6.0.tar.xz

(或者直接:tar -xf Python-3.6.0.tar.xz)

进入安装包中,查看 README 文件,有安装提示:

Build Instructions

On Unix, Linux, BSD, OSX, and Cygwin:

./configure

make

make test

sudo make install

This will install Python as python3.

查看更多编译选项:

./configure --help

默认安装目录为 PREFIX 为 /usr/local,程序文件会安装到 /usr/local/bin, /usr/local/lib 等位置。

make test 报错:

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

ERROR: test_idna (test.test_socket.GeneralModuleTests)

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

Traceback (most recent call last):

File "/root/Python-3.6.0/Lib/test/test_socket.py", line 1337, in test_idna

socket.gethostbyname(domain)

socket.gaierror: [Errno -3] Temporary failure in name resolution

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

Ran 539 tests in 148.041s

FAILED (errors=1, skipped=24)

test test_socket failed

2 tests failed again:

test_dbm test_socket

Total duration: 15 min 17 sec

Tests result: FAILURE

make: *** [test] Error 1

还是 make install,最后显示:

Collecting setuptools

Collecting pip

Installing collected packages: setuptools, pip

Successfully installed pip-9.0.1 setuptools-28.8.0

python的执行命令安装在了 /usr/local/bin 下面,因为 $PATH 路径已经包含这个路径,所以可以直接在命令行执行 python3 命令。

[root@vm1 etc]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值