解决:无法将Python识别为内部或外部命令

Hello, Programmers! Many of us have already worked with Python and at some point in time we all have faced this error of “Python is not recognized as an internal or external command”.

您好,程序员! 我们中的许多人已经使用过Python,并且在某个时间点我们都遇到了以下错误:“ Python不被识别为内部或外部命令”。

Now, this error is shown to us mainly because of two reasons. Either your system don’t have python installed or maybe it is installed but the path of Python is not configured properly.

现在,向我们显示此错误的原因主要有两个。 您的系统未安装python,或者可能已安装,但是Python的路径配置不正确。

In this post, we’ll see both the reasons for this error and we’ll try to fix this.

在这篇文章中,我们将看到导致此错误的两个原因,并尝试对其进行修复。

未安装Python (Python is Not Installed)

Sometimes we don’t have python installed on our system but when we try to run python from the command line or the Powershell, this throws us an error of Python is not recognized.

有时我们的系统上没有安装python,但是当我们尝试从命令行或Powershell运行python时,这会向我们抛出一个无法识别Python错误

Now to overcome this error, open your browser and download the latest version of Python for your PC and install it on your system.

现在要解决此错误,请打开浏览器并为PC下载最新版本的Python,然后将其安装在系统上。

While installing, don’t forget to check the box that says, Add Python to PATH. This will install and also set the path for you at the same time.

安装时,不要忘记选中“ Add Python to PATH ”复选框。 这将安装并同时为您设置路径。

Not open you command prompt or the Powershell and type Python and this will open the python shell in that command prompt or that Powershell.

不打开命令提示符或Powershell并键入Python ,这将在该命令提示符或Powershell中打开python shell。

If this was the reason for your “Python is not recognized” problem, I guess you got your solution.

如果这是导致“无法识别Python”问题的原因,那么我想您已经找到了解决方案。

Next step is for those who already installed Python on their PC but still, it is not showing it in your command prompt or the Powershell.

下一步是针对那些已经在其PC上安装了Python但仍未在命令提示符或Powershell中显示它的用户。

设定Python的路径 (Setting the Path of Python)

This is one of the reasons why many of us get this error. We install our Python but we forget to set the path of Python and thus it throws us an error.

这是我们许多人收到此错误的原因之一。 我们安装了Python,但忘记了设置Python的路径,因此会抛出错误。

  1. To configure the path of Python properly, open you file explorer and navigate to the folder where you’ve installed Python on you PC.

    要正确配置Python的路径,请打开文件浏览器,然后导航到PC上安装Python的文件夹。
  2. You’ll find it somewhere in your Program Files folder.

    您可以在Program Files夹中的某个位置找到它。

  3. Next step is to open the folder and copy its path.

    下一步是打开文件夹并复制其路径。
  4. Now we have the path of Python, we can now click on Start and search for Edit the System Environment Variables.

    现在我们有了Python的路径,现在我们可以单击Start并搜索Edit the System Environment Variables。

  5. Now click on Environment Variables. Now double click on Path.

    现在单击环境变量。 现在双击路径。

  6. Now click on New and their paste you path of Python which you copied earlier.

    现在单击“ 新建”,并粘贴您先前复制的Python路径。

Now click ok and you are done with the path setup.

现在单击“确定”,完成路径设置。

You can now try to open command prompt and type python and hit enter. This will show the version of python installed and a python shell will be opened in that command prompt.

现在,您可以尝试打开命令提示符并键入python,然后按Enter。 这将显示已安装的python版本,并且将在该命令提示符中打开python shell。

If you have found this post helpful, please share it with your friends or colleagues who are looking for some python programming.

如果您发现这篇文章有帮助,请与正在寻找python编程的朋友或同事分享。

And if you have started with Python development and stuck in some kind of problem or bug, you can leave your comment here and we will get back to you soon.

而且,如果您开始使用Python开发并且遇到某种问题或错误,可以在这里留下您的评论,我们会尽快与您联系。

翻译自: https://www.thecrazyprogrammer.com/2020/08/python-is-not-recognized-as-an-internal-or-external-command.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值