
开启之后,会提示你重启电脑才能使配置生效,我们重启即可。
电脑重启后,打开Microsoft Store搜索WSL,既可以看到支持的操作系统,我们选择Ubuntu即可,我们选择第一个就可以。

随后我们打开,发现报错,这是由于升级到WSL2后缺少对应linux内核导致的
Installing, this may take a few minutes… WslRegisterDistribution
failed with error: 0x800701bc Error: 0x800701bc WSL 2 ??? https://aka.ms/wsl2kernelPress any key to continue…

我们前往微软官网下载更新一下就可以了。下载地址如下:
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
点击next后就安装成功了。

此时我们再次打开ubuntu,再次报错:
Installing, this may take a few minutes… WslRegisterDistribution
failed with error: 0x80370102 Please enable the Virtual Machine
Platform Windows feature and ensure virtualization is enabled in the
BIOS. For information please visit https://aka.ms/enablevirtualization
Press any key to continue…
此时以管理员身份打开PowerShell,执行下面的命令。
# 启用适用于 Linux 的 Windows 子系统
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# 启用虚拟机功能
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

发现还是不行,这时我们输入下面的命令。
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
运行完毕后电脑会重启,此时再次打开便正常了:

此外,我们可以选择打开方式,我们使用Windows Terminal,Win11是默认安装的。

这样就OK了。

我们安装的系统默认是在C盘的,其路径为:
C:\Users\pengxiang\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc
随后,我们需要更换一下数据源:
# 切换至root用户后,执行下述指令
# 备份旧的镜像源文件
$ mv /etc/apt/sources.list /etc/apt/sources.list.bk
# 更换为阿里源
$ vi /etc/apt/sources.list
#在该文件内添加下面的镜像路径
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
# 更新软件
$ apt-get update








![[Python学习篇] Python创建项目](https://img-blog.csdnimg.cn/direct/02e2e4270dd94da18937f6b4d0746b16.png)










