20250709: WSL+Pycharm 搭建 Python 开发环境

一、说明

1.代码和解释器的位置

1.1 代码在 Windows,解释器在 WSL 。

1.2 代码 & 解释器都在 WSL。

注:1.无论哪个组合,打开 terminal 的时候都无法自动激活虚拟环境,需要手动激活。

2.流程概述

2.1 安装 WSL

限于篇幅,不做详细介绍,参考:https://learn.microsoft.com/zh-cn/windows/wsl/install。

2.2 安装 Python

安装在 WSL 里面,使用以下命令进行安装:

sudo apt install python

2.3 安装 Pycharm

安装在 windows。限于篇幅,不做详细介绍,参考:。

2.4 设置解释器

使用 WSL 里面的 Pyrthon。

二、“代码 & 解释器都在 WSL”搭建流程

1.点击 File > Open
202507091_1

2.选择位于 WSL 里面的项目
202507091_2

3.点击Pycharm 右下角的 Python Interpreter selector,选择 On WSL...
202507091_3

4.点击 Next
202507091_4

5.创建解释器
202507091_5

6.打开 terminal, 手动激活虚拟环境
202507091_6

三、“代码在 Windows,解释器在 WSL”搭建流程

1.点击 File > Open
202507092_1

2.选择位于 WSL 里面的项目
202507092_2

3.点击Pycharm 右下角的 Python Interpreter selector,选择 On WSL...
202507092_3

4.点击 Next
202507092_4

5.创建解释器
202507092_5

6.打开 terminal, 手动激活虚拟环境

202507092_6

codist_mp

欢迎搜索及关注:编程人(a_codists)

posted @ 2025-07-09 19:48  codists  阅读(425)  评论(0)    收藏  举报