简体   繁体   English

如何从 Windows 命令提示符启用“空闲”命令

[英]How to enable the "idle" command from Windows Command Prompt

I remember that at some point I used to be able open up the python IDLE from the command line by simply typing "idle" return, which would pop up the python idle editor.我记得在某个时候,我曾经可以通过简单地输入“idle”返回从命令行打开 python IDLE,这会弹出 python idle 编辑器。 I recently got a new machine and installed python, but have to open idle from the windows start menu.我最近买了一台新机器并安装了python,但必须从windows开始菜单中打开idle。

When trying to run "idle" or "idle3" from the command line I get尝试从命令行运行“idle”或“idle3”时,我得到

C:\Users\SSims>idle3
'idle3' is not recognized as an internal or external command,
operable program or batch file.

Can anyone tell me how to get the command line "idle" command set up.谁能告诉我如何设置命令行“空闲”命令。 Thanks for any help!谢谢你的帮助!

There are no step-by-step fixes that I have found online to answer this question, but many that answer specific portions of the question scattered around online.我在网上找到的没有分步修复来回答这个问题,但有很多可以回答分散在网上的问题的特定部分。 Hopefully, this will help others with the same question in the future, as I know there are many who could benefit from this answer.希望这会帮助其他人在未来遇到同样的问题,因为我知道有很多人可以从这个答案中受益。

If you have selected "Add Python Xx to Path Variables" upon installation then you should be able to run "python" from the command line to start the python editor.如果您在安装时选择了“将 Python Xx 添加到路径变量”,那么您应该能够从命令行运行“python”以启动 Python 编辑器。 Similarly, this will allow you to do the same for IDLE.同样,这将允许您对 IDLE 执行相同的操作。

First, hit your windows key and type "path" then enter to go to your system environment page in settings.首先,点击您的 Windows 键并输入“路径”,然后在设置中进入您的系统环境页面。

在此处输入图片说明

Next, click "Environment Variables then select "Path" under user variables There should be a popup that contains a path that looks like this:接下来,单击“环境变量”,然后在用户变量下选择“路径”应该会有一个包含如下路径的弹出窗口:

C:\\Users\\SSims\\AppData\\Local\\Programs\\Python\\Python37-32\\

Copy that address then click "new" Paste that address, then at the end of it type "Lib\\idlelib" so that your new variable now looks like:复制该地址,然后单击“新建”粘贴该地址,然后在其末尾键入“Lib\\idlelib”,这样您的新变量现在看起来像:

C:\\Users\\SSims\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\idlelib

This should be the path to the folder in which the idle executable file resides.这应该是空闲可执行文件所在文件夹的路径。

Note: You can check that path to ensure it is right by pasting it into the windows start menu and it should redirect you to the folder.注意:您可以通过将其粘贴到 Windows 开始菜单中来检查该路径以确保它是正确的,并且它应该将您重定向到该文件夹​​。 If it doesn't, you can paste the path to the python folder from earlier that was added automatically upon installation and search around in there until you find the idle executable, then add that folder to the Path variables to get it to work.如果没有,您可以粘贴之前安装时自动添加的 python 文件夹的路径,并在那里搜索直到找到空闲的可执行文件,然后将该文件夹添加到 Path 变量以使其工作。

You should now be able to run the idle command from command prompt, hope this helps!!您现在应该可以从命令提示符运行 idle 命令,希望这会有所帮助!!

Instead of IDLE use, python -m idlelib command代替 IDLE 使用, python -m idlelib命令

check the IDLE official document查看IDLE官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM