时间:2020-06-25 python教程 查看: 1651
参考文章
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```
<p><span style="color: #ff0000"><strong>正式开始</strong></span></p>
<p>下载python文件</p>
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```
<p>创建python安装路径</p>
sudo mkdir /usr/python37```
安装python
sudo ./configure --enable-optimizations --prefix=/usr/python37
sudo make && make install```
<p>添加环境变量</p>
sudo vim /etc/profile```
在结尾添加
export PATH=$PATH:/usr/python37/bin
alias python="python3.7"
alias pip="pip3.7"```
<p style="text-align: center"><img alt="" src="//img.jbzj.com/file_images/article/202006/20206892830714.png?2020589305"></p>
<p><span style="color: #ff0000"><strong>添加用户别名</strong></span></p>
vim ~/.bashrc```
在结尾添加
alias python="python3.7"
alias pip="pip3.7"```
<p style="text-align: center"><img alt="" src="//img.jbzj.com/file_images/article/202006/20206892830715.jpg?20205893035"></p>
<p>创建软连接</p>
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```
<p>添加如下内容</p>
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple```
更新pip
sudo pip install --upgrade pip
总结
到此这篇关于给ubuntu18安装python3.7的详细教程的文章就介绍到这了,更多相关ubuntu18安装python3.7内容请搜索python博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持python博客!