windows下Ubuntu子系统配置python
因为下学期会有python课程,所以想先预习预习,可楼主用VS Code和Eclipse调了半天,愣是没把环境配好,网上的教程多是ubuntu的,正巧现在windows自带linux子系统了,所以就愉快的在Ubuntu下编程了(还不是因为windows下的环境不会配)
首先开启Windows的Linux子系统功能
在开发者选项下启用开发者模式,安装开发者包可能要等一会
直接用小娜搜索Windows功能就行了
然后启用linux的功能
然后进入Microsoft store
直接搜索linux或者Ubuntu都可以
安装好以后打开根据提示Wait a moment ,创建账号就可以了。
进入以后可以改一下源(我的习惯)
sudo su
passwd root
改下root密码,直接用root装软件了,懒得打sudo
然后备份一下
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
把底下两个源其中一个添加或者覆盖写到文件里就行了
PS:如果提示vim有错误,可能是没安装,执行一下下面的代码就可以
apt-get install vim
这里提供两个源
##这是阿里的源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
##清华的源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
还有很多源可以找度娘。
然后更新一下,可能时间要很久
apt-get uodate ##更新源
apt-get upgrade ##更新软件
python3版本是内置在这个版本的Ubuntu下的,要使用直接
python3 文件名.py
如果要使用python2.7,执行以下代码
apt-get install python
就可以
python 文件名.py
python环境就配好了