mac下安裝pyenv,直接brew安裝即可
由于直接下python不可下載,可以用迅雷下載好,然后用python2 或者python3 起一個http服務
然后需要把文件名用sha64轉碼,然后通過127.0.0.1:port能夠訪問到,
然后就是設置環(huán)境變量export PYTHON_BUILD_MIRROR_URL=127.0.0.1:port/
運行命令 pyenv install 2.7.2
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.2.tgz...
/usr/local/Cellar/pyenv/1.2.21/plugins/python-build/bin/python-build: line 351: 56337 Abort trap: 6 aria2c --dry-run --no-conf=true 1" 1>&4 2>&1
-> https://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
error: failed to download Python-2.7.2.tar.gz
BUILD FAILED (OS X 11.1 using python-build 20180424)
然后就會報這個錯,因為aria2c這個工具不好使原因,需要把/usr/local/Cellar/pyenv/1.2.21/plugins/python-build/bin 這個目錄下的python-build的339的函數(shù)改為
detect_http_client() {
local client
for client in curl wget aria2c; do
if type "$client" &>/dev/null; then
echo "$client"
return
fi
done
echo "error: please install `aria2c`, `curl`, or `wget` and try again" >&2
return 1
}
把 aria2c 排到最后,然后原理就是使用 curl 或者 wget 下載最新版本的python。
然后還是build failed ,
報錯如下
BUILD FAILED (OS X 11.1 using python-build 20180424)
然后用brew 重新安裝 zlib就行了,然后依照安裝完成后的提示,配和環(huán)境變量,然后在進行安裝就可以成功安裝了。