亲宝软件园·资讯

展开

ubuntu18安装python3.7 给ubuntu18安装python3.7的详细教程

myself_oriented 人气:0

参考文章
ubuntu源码安装python3
linux 编译安装python3.6的教程详解

准备工作

安装工具

sudo apt update
sudo apt upgrade
sudo apt install gcc
sudo apt install g++
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

正式开始

下载python文件

sudo curl -O https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz

解压源码包

sudo tar Jxvf Python-3.7.1.tar.xz

创建python安装路径

sudo mkdir /usr/python37

安装python

sudo ./configure --enable-optimizations --prefix=/usr/python37
sudo make && make install

添加环境变量

sudo vim /etc/profile

在结尾添加

export PATH=$PATH:/usr/python37/bin
alias python="python3.7"
alias pip="pip3.7"

添加用户别名

vim ~/.bashrc

在结尾添加

alias python="python3.7"
alias pip="pip3.7"

创建软连接

sudo ln -s /usr/python37/bin/python3.7 /bin/python
sudo ln -s /usr/python37/bin/pip3.7 /bin/pip

更换国内源

cd ~
mkdir .pip
cd .pip
> pip.conf
vim pip.conf

添加如下内容

[global]
index-url = http://pypi.tuna.tsinghua.edu.cn/simple

更新pip

sudo pip install --upgrade pip

总结

加载全部内容

相关教程
猜你喜欢
用户评论