WSL 是否使用 Windows 主机上安装的 python 安装?

问题描述 投票:0回答:2

我的 Windows 机器上安装了一些 Python。最近需要Linux环境来学习。我的问题是“我需要在 WSL 环境中再次安装 Python 吗?或者不需要(因为 WSL 使用与 Windows 主机相同的 python 安装)”。请给我答案,先谢谢你了?

python windows-subsystem-for-linux
2个回答
0
投票

使用 Windows Subsystem for Linux (WSL) 时,默认情况下您没有使用与 Windows 主机相同的 Python 安装。 WSL 运行自己独立的 Linux 发行版,如果您想使用它,您需要在该环境中安装 Python。

您可以使用特定发行版的包管理器在 WSL 发行版中安装 Python。例如,在 Ubuntu 上,您可以使用 apt 包管理器通过运行命令

sudo apt install python3
来安装 Python。

总之,如果您想在 WSL 环境中使用 Python,则需要在 WSL 环境本身中安装它。


0
投票

不,他们使用 Linux 发行版中的 Python。您可以通过运行

ls -l $(which python)
ls -l $(which python3)
或仅在 WSL 中运行 Python(在 Windows 计算机上未安装 Python)来确定。

© www.soinside.com 2019 - 2024. All rights reserved.