bash 如何让`python`在WSL bash中运行Python 3?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48524196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:47:45  来源:igfitidea点击:

How to get `python` to run Python 3 in WSL bash?

pythonbashwindows-10windows-subsystem-for-linux

提问by urig

When I type pythoninto my bash shell (Windows Subsystem for Linux) in Windows 10 Home, I get the following error message:

当我python在 Windows 10 Home 中输入我的 bash shell(适用于 Linux 的 Windows 子系统)时,我收到以下错误消息:

The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

I've tried installing python3but am told it's already installed and up to date.

我试过安装,python3但被告知它已经安装并且是最新的。

I've tried uninstalling python-minimalbut am told it's not installed (!)

我试过卸载,python-minimal但被告知它没有安装(!)

Why am I seeing two "competing" packages for Python? How can I fix the conflict and configure my WSL bash to run Python 3 from python?

为什么我看到两个 Python 的“竞争”包?如何解决冲突并配置我的 WSL bash 以运行 Python 3 python

回答by Srdjan Grubor

pythonin linux world as a CLI command almost always means python2and not python3. Make sure that you have python2installed (sudo apt install python).

python在 linux 世界中作为 CLI 命令几乎总是意味着python2而不是python3. 确保您已python2安装 ( sudo apt install python)。

DO NOTalias pythonto python3- this is some bad advice!

不要别名pythonpython3-这是一些不好的建议!

To run python3, you have to specify python3on the CLI.

要运行python3,您必须python3在 CLI上指定。