Using Linux (centos7) through wsl2 under window

Install centos7

centos7 mirror: https://github.com/mishamosher/CentOS-WSL/releases/download/7.9-2111/CentOS7.zip

The Linux subsystem does not provide a centos7 image by default. You can download the image above and refer to this article to install it: Windows 11 builds WSL to run CentOS7 (one of the WSL+Pycharm environment building series)

Install python3:

To install python3 in WSL subsystem CentOS7 , the approximate instructions are as follows

# 安装编译相关工具
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install libffi-devel -y

# 下载python安装包
wget http://npm.taobao.org/mirrors/python/3.9.9/Python-3.9.9.tgz
tar -zxvf  Python-3.9.9.tgz

# 安装gcc
yum install gcc

# 编译安装python
cd Python-3.9.9
./configure --prefix=/usr/local/python3
make && make install

vi /etc/profile # 修改/etc/profile
export PATH=/usr/local/python3/bin:$PATH #把这一句加入profile末尾,就是添加环境变量 wq保存
source /etc/profile  ## 重载
# 进入python3 查看版本
python3

Usage: Refer to Linux Learning

cd /mnt #挂载系统盘符
ls  #可查看所有盘符
pwd #显示当前路径

Set proxy for wsl2: Set proxy for WSL2 with one click . wsl1 and window share network ports, while wsl2 is independent of each other. The agent software must be turned on to run Lan

cat /etc/resolv.conf  #执行后可以看到dns服务器ip,该ip即为宿主window的ip,通过该ip+代理监听端口号设置就好
ipconfig #或者在window下执行该命令获取wsl的ip

Please indicate when reprinting:

Author: vision
Article title: Application of copilot in Pycharm
Article source: 1: My research path ; 2: vision_wang’s csdn

おすすめ

転載: blog.csdn.net/vision666/article/details/129898214