python - 从源码安装 Python3.7
问题描述
我需要使用 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
解决方案
我将您的脚本调整为在 Ubuntu 20.04 实例上用作UserData脚本:
#!/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}
推荐阅读
- reactjs - TypeError: Object(...) 不是反应中的函数
- mysql - 按mysql排序后选择第一行
- php - 如何在变量中插入新行以创建 Qrcode
- php - 尝试用两个可能的外键定义关系
- sql - 在 PostgreSQL 中除以两个运行总计
- listagg - 在 Orcale 中使用 LISTAGG - ORA-00937:不是单组组函数
- java - RabbitMQ 错误 java.util.concurrent.TimeoutException: null
- python - 拆分python pandas Dataframe中列的内容并使用新分离的字符串列表创建一个新的Dataframe
- c++ - 应用程序在将数据上传到数据库之前关闭,Qt
- ruby-on-rails - 部署成功后active_admin登录失败