ubuntu18安装Python3.7
Pinocchio
Pinocchio
Python爬虫、数据挖掘、人工智能
ubuntu18安装Python3.7
ubuntu18系统自带了python2.7和python3.6;不要卸载ubuntu自带的python版本;ubuntu下不同版本的python可以共存,可直接安装python3.7。
1.升级包索引和软件
sudo apt update
sudo apt upgrade -y
2.安装编译所需包
sudo apt install build-essential zlib1g-dev libbz2-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
3.下载Python3.7
官网下载Python-3.7.4.tgz文件
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
4.解压Python安装包
tar -xzvf Python-3.7.4.tgz
5.编译和安装
cd Python-3.7.4
./configure --prefix=/usr/local/src/python37 # 配置安装位置
sudo make
sudo make install
6.建立软连接
sudo ln -s /usr/local/src/python37/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/src/python37/bin/pip3.7 /usr/bin/pip3.7
接下来你就可以使用python3.7,而不会影响系统自带的python2.7和python3.6
如果你想用python3.7替换掉系统默认的python3
sudo rm -rf /usr/bin/python3
sudo ln -s /usr/local/src/python37/bin/python3.7 /usr/bin/python3
默认ubuntu系统中没有pip3,直接建立软连接即可。
sudo ln -s /usr/local/src/python37/bin/pip3.7 /usr/bin/pip3
输入python3默认就是你安装好的python3.7了
7.pip换源
创建目录:sudo mkdir ~/.pip
创建文件:sudo gedit ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com