蔡妈看看

我们不是代码的搬运工,我们只生产代码

win10 子系统Ubuntu 16.04.2 LTS 编译安装Python

在普通安装的linux(包括centos、ubuntu)都自带了python 今天使用win的子系统时却发现, 逆天了。。。

win10的bash子系统没有python, 并且使用apt-get install 也只有发现python3 今天就手动编译安装一个python2.7

先把apt的源换了

admxj@ADM-PC:~$ vim /etc/apt/sources.list
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse                                                            

更新一下仓库

sudo apt-get update 

安装GCC

sudo apt-get install build-essential 

安装python 2.7
在python 官网上下载2.7 版本的source code。网址如下:

https://www.python.org/downloads/release/python-2714/

《win10 子系统Ubuntu 16.04.2 LTS 编译安装Python》点击上面的XZ compressed source tarball 便可以下载一个tar.xz的压缩包

把下载的压缩包上传到ubuntu, 可以通过访问 /mnt 挂载点访问windows的文件

如果没有xz 安装xz-utils

sudo apt-get install zx-utils
xz -d Python-2.7.14.tar.xz
tar -xvf Python-2.7.14.tar
cd Python-2.7.14
./configure

 

点赞

发表评论