1 Star 0 Fork 18

andy_chen/kiauh

forked from mirokymac/kiauh 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install_python3.sh 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
# author: mirokymac 2021-11-21
# using ustc source
echo "This script will check Python3 version.\nIf Python3 < 3.7 then mods the deps and install python3.\nThe compiling will take about 20 min on RPi3."
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cat > /etc/apt/sources.list<<EOF
# simple USTC http sources
deb http://mirrors.ustc.edu.cn/debian/ stretch main contrib non-free
EOF
mkdir -p ~/backup/apt.d/
sudo mv /etc/apt/sources.list.d/* ~/backup/apt.d/
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y ca-certificates
### python 3 check and mods
echo "Your Python 3 version is: $(python3 --version)"
py_chk_ok=$(python3 -c 'import sys; a, b = sys.version_info[:2]; print(a+b/10 >=3.7)')
main_python3="$(python3 -c 'import sys; a, b = sys.version_info[:2]; print(a+b/10)')"
sudo apt-get upgrade -y
sudo apt-get install -y python3-virtualenv
if [ $py_chk_ok = "False" ];then
# set -e
sudo sed -i "s/python3/python${main_python3}/g" /usr/bin/virtualenv
sudo sed -i "s/python3/python${main_python3}/g" /usr/bin/lsb_release
PYTHONDEP="make build-essential libssl-dev zlib1g-dev libbz2-dev"
PYTHONDEP="${PYTHONDEP} libreadline-dev libsqlite3-dev wget curl"
PYTHONDEP="${PYTHONDEP} llvm libncurses5-dev xz-utils tk-dev libffi-dev"
sudo apt-get install -y ${PYTHONDEP}
# ali npm mirror
wget https://registry.npmmirror.com/-/binary/python/3.8.12/Python-3.8.12.tar.xz
tar -xf ./Python-3.8.12.tar.xz
cd ./Python-3.8.12
./configure --enable-optimizations
make -j4
sudo make altinstall
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.8 2
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${main_python3} 1
sudo update-alternatives --auto python3
echo "\n\n"
echo "Python3 install finished."
echo "To rewrite the APT sources, run the commands below:"
echo "\tsudo mv ~/backup/apt.d/* /etc/apt/sources.list.d/"
echo "\tsudo rm /etc/apt/sources.list"
echo "\tsudo mv /etc/apt/sources.list.bak /etc/apt/sources.list"
echo "\tsudo rm -rdf ~/backup/apt.d"
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/czp909035688/kiauh.git
git@gitee.com:czp909035688/kiauh.git
czp909035688
kiauh
kiauh
master

搜索帮助