python - 从源码安装 Python3.7

标签 python amazon-web-services ubuntu

我需要使用 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/

相关文章:

python - 使用 Homebrew 在 Snowleopard 上升级 Python 现在 pip 和 easy_install 不起作用

java - Play Framework 应用程序默认使用多少最大堆空间

windows - ec2 block 设备映射列表与 Windows 驱动器之间的映射

ubuntu - (增量)重建 Debian/Ubuntu 软件包

python - 使用 psycopg2 将 pandas DataFrame 快速插入到 Postgres DB 中

python - Pandas:使用 Append 添加新列并使另一个全为 NaN

python - 返回Python的for循环

amazon-web-services - 对 AWS 特定参数类型强制执行非空验证

python - 无法读取远程 Ubuntu 服务器上 flask 中保存的机器学习模型

linux - 获取目录中每个文件的 "Head"?