Win11 WSL Linux子系统安装与注销 配置conda环境 启动jupyter

1 前言

本篇博客讲解如何在Windows11系统中安装与注销Linux子系统,并配置conda环境、jupyter环境,实现在Local浏览器启动jupyter并运行项目。

2 安装Linux子系统(参考文章[1])

2.1 WSL

  1. 在任务栏中的搜索功能中,搜索“启用或关闭 windows 功能”,确保以下两者处于启动状态。若原本为禁用,改为启用后需要重启电脑;若原本为启用,则不需要重启。
    在这里插入图片描述
  2. 打开PowerShell,输入以下指令
bcdedit /set hypervisorlaunchtype auto

2.2 安装Linux系统

  1. 输入以下指令安装ubuntu
wsl --install -d Ubuntu
  1. 或者,在Microsoft应用商店选择自己喜欢的系统版本安装(搜索关键词:linux;ubuntu都行)
    在这里插入图片描述
    在这里插入图片描述

  2. 安装完成后,直接在下载的页面点击“Open”或“启动”,会弹出子系统的终端窗口。不出意外的话,里面会显示一串“正在安装配置系统”的英文,等待安装完成即可。

  3. 安装完成后,会提示输入创建用户名与密码,输入即可。

3 安装Miniconda环境

  1. 下载最新版miniconda3
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  1. 在下载的目录下运行这个指令
sh Miniconda3-latest-Linux-x86_64.sh
  1. 重启终端,看到有“(base)"字样,即安装成功.
  2. 安装gcc/g++
sudo apt-get install build-essential
  1. 配置镜像源(参考文章[3])
conda config
# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
 
# 添加阿里云镜像源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
 
# 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
  1. 创建虚拟环境
conda create -n env_name python=3.8
  1. 先把需要安装的python包放在一个txt文件内,以换行符隔开并保存。进入windows下的保存txt文件的位置:(通常情况下,从子系统访问本地机器目录,需要切换到/mnt/路径下,/mnt/c表示C盘,/mnt/d表示D盘,以此类推)
cd /mnt/your_path/
  1. 执行以下指令,将txt内所有包进行安装
pip install -r pkgs.txt

4 安装并在本地机浏览器打开Jupyter

  1. 安装jupyter,以下两个指令运行其中一个即可。
conda install jupyter
pip install jupyter
  1. 安装net-tools
sudo apt install net-tools
  1. 查看子系统的ip,复制
ifconfig

在这里插入图片描述

  1. 启动jupypter
jupyter notebook --ip=刚才复制的ip地址
  1. 复制这段链接,粘贴到本地机浏览器内即可访问jupyter 在这里插入图片描述

5 删除并注销子系统

  1. 查看安装了哪些系统
wslconfig /l
  1. 注销所安装的系统,并清除文件。下面的“系统名”为上一段指令显示出来的系统名,指定一个名字复制下来即可。
wslconfig /u 系统名

参考文章

[1] https://zhuanlan.zhihu.com/p/475462241
[2] https://www.jianshu.com/p/47ed480daccc
[3] https://blog.csdn.net/qq_32650831/article/details/127952502

其他

By the way,记录一下latex环境报错(RuntimeError: Failed to process string with tex because latex could not be found)问题的解决方法

pip install latex
sudo apt-get install dvipng
sudo apt-get install -y texlive texlive-latex-extra texlive-latex-recommended
sudo apt-get install cm-super
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值