linux(Ubuntu)安装python
Linux下安装python
提前安装一个依赖环境
(1)ubuntu/Debian:
sudo apt-get install -y gcc make cmake build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
(2)Fedora/CentO S/RHEL(aws ec2):
sudo yum install gcc make cmake zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
安装步骤:(可提前进入root,需要建立文件夹)
1.下载:
wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tgz (注意大小写)
2.解压Python-3.7.7.tgz
tar -zxvf Python-3.7.7.tgz
4、建立一个空文件夹,用于存放python3程序
mkdir /user/local/python3
5、执行配置文件,编译,编译安装
cd Python-3.7.7
./configure --prefix=/usr/local/python3
make && make install
(安装完成没有提示错误便安装成功了)
6、建立软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
(第一个软链接建立的时候,系统提示已存在,但后面程序可正常运行)
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
7、测试一下python3是否可以用
python3
print(”hello world!“)
hello world!
exit()
出处:https://www.cnblogs.com/mushi-01/p/16048945.html