我需要使用 Python3.7,所以我按照这些说明进行安装
curPath=${pwd}
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
sudo tar xzf Python-3.7.9.tgz
cd Python-3.7.9
sudo ./configure --enable-optimizations
cd ${pwd}
然后我尝试运行 python -V
并得到Command 'python3.7' not found, did you mean:
command 'python2.7' from deb python2.7 (2.7.18-1~20.04)
command 'python3.9' from deb python3.9 (3.9.0-5~20.04)
command 'python3.8' from deb python3.8 (3.8.5-1~20.04.2)
Try: sudo apt install <deb name>
我也尝试运行 whereis python
并得到whereis python
python: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/lib/python3.8 /usr/lib/python2.7 /usr/lib/python3.9 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8
最佳答案
我修改了您的脚本以用作 UserData Ubuntu 20.04 实例上的脚本:
#!/bin/bash
apt update
apt install -y build-essential zlib1g-dev
curPath=${pwd}
cd /usr/src
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar xzf Python-3.7.9.tgz
cd Python-3.7.9
#./configure --enable-optimizations
./configure
make
make install
cd ${pwd}
关于python - 从源码安装 Python3.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66380450/