pyenv下载失败问题处理


问题描述

使用pyenv获取python版本的时候, 报错error: failed to download Python-3.6.4.tar.xz

$ pyenv install 3.6.4
Downloading Python-3.6.4.tar.xz...
-> https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
error: failed to download Python-3.6.4.tar.xz

BUILD FAILED (Ubuntu 17.04 using python-build 1.2.1-17-g907a86b)

重新安装libssl-dev 也没有效果.

sudo apt-get remove libssl-dev
sudo apt-get install libssl-dev

或者 使用PYTHON_BUILD_MIRROR_URL 也没有效果

$ export PYTHON_BUILD_MIRROR_URL="http://yyuu.github.io/pythons/"
$ pyenv install 2.7.7

解决方法

先使用$ wget -P $(pyenv root)/cache https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz,
然后运行 $ pyenv install 3.6.4.

$ wget -P $(pyenv root)/cache https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
--2018-02-12 17:45:26--  https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
正在解析主机 www.python.org (www.python.org)... 151.101.228.223
正在连接 www.python.org (www.python.org)|151.101.228.223|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 16992824 (16M) [application/octet-stream]
正在保存至: “/home/itaken/.pyenv/cache/Python-3.6.4.tar.xz”

Python-3.6.4.tar.xz 100%[===================>]  16.21M  2.06MB/s    in 12s     

2018-02-12 17:45:38 (1.37 MB/s) - 已保存 “/home/itaken/.pyenv/cache/Python-3.6.4.tar.xz” [16992824/16992824])

$ pyenv install 3.6.4
Installing Python-3.6.4...
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Installed Python-3.6.4 to /home/itaken/.pyenv/versions/3.6.4

切换python版本

$ pyenv versions                                                          1 ↵
* system (set by /home/itaken/.pyenv/version)
  2.7.14
  3.5.5
  3.6.4
  anaconda-2.4.0
  anaconda3-5.0.0

$ pyenv global 3.6.4
$ python --version
Python 3.6.4

参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录