Python 上下文菜单中缺少“使用空闲编辑”选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29179631/
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
"Edit with IDLE" option missing from context menu
提问by nokalake
I have Python 2.7.5 that installed with ArcGIS 10.2.2. When I first right-clicked a .py script I'd previously written it listed the "Edit with IDLE" option in the context menu. However, this option no longer appears when I right-click a .py file.
我有安装了 ArcGIS 10.2.2 的 Python 2.7.5。当我第一次右键单击我之前编写的 .py 脚本时,它在上下文菜单中列出了“Edit with IDLE”选项。但是,当我右键单击 .py 文件时,此选项不再出现。
I have read numerous threads concerning this issue and attempted some of them, such as modifying/removing registry keys and then reinstalling/repairing the software. I am not interested in using an IDE at this point, though many will be happy to know I intend to use an IDE later on. Right now, the purpose is to fix the problem rather than avoid and work around it.
我已经阅读了许多有关此问题的线程并尝试了其中的一些线程,例如修改/删除注册表项,然后重新安装/修复软件。目前我对使用 IDE 不感兴趣,尽管许多人会很高兴知道我打算稍后使用 IDE。现在,目的是解决问题,而不是避免和解决问题。
I appreciate the help I've gotten from the online community in the past, and I'm confident someone will come through with a solution for me.
我感谢过去从在线社区获得的帮助,我相信有人会为我提供解决方案。
How do I get "Edit with IDLE" back in the context menu?
如何在上下文菜单中返回“使用空闲编辑”?
采纳答案by Teodorico Levoff
Directly from: https://superuser.com/questions/343519/python-idle-disappeared-from-the-right-click-context-menu
直接来自:https: //superuser.com/questions/343519/python-idle-disappeared-from-the-right-click-context-menu
Here's a reg file to add the command to edit with IDLE for Python.File (.py) and Python.NoConFile (.pyw) file types. It's for Python 2.7, installed in C:\Python27, so substitute the paths to pythonw.exe and idle.pyw that are relevant to your installation. Save it to a .reg file. Then right-click and choose Merge.
这是一个 reg 文件,用于添加使用 IDLE 编辑 Python.File (.py) 和 Python.NoConFile (.pyw) 文件类型的命令。它适用于安装在 C:\Python27 中的 Python 2.7,因此请替换与您的安装相关的 pythonw.exe 和 idle.pyw 路径。将其保存为 .reg 文件。然后右键单击并选择合并。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command]
@="\"C:\Python27\pythonw.exe\" \"C:\Python27\Lib\idlelib\idle.pyw\" -e \"%1\""
[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Edit with IDLE\command]
@="\"C:\Python27\pythonw.exe\" \"C:\Python27\Lib\idlelib\idle.pyw\" -e \"%1\""
回答by nokalake
Adding a little more detail to Teodorico Levoff's answer for those who need a little more explanation, like myself.
为像我这样需要更多解释的人,在 Teodorico Levoff 的回答中添加更多细节。
Open a text editor, such as Notepad, and copy/paste the following, but be sure to modify the paths to pythonw.exe and idle.pyw so that they match the paths in your own system:
打开记事本等文本编辑器,复制/粘贴以下内容,但一定要修改 pythonw.exe 和 idle.pyw 的路径,使它们与您自己系统中的路径匹配:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command]
@="\"C:\Python27\pythonw.exe\" \"C:\Python27\Lib\idlelib\idle.pyw\" -e \"%1\""
[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Edit with IDLE\command]
@="\"C:\Python27\pythonw.exe\" \"C:\Python27\Lib\idlelib\idle.pyw\" -e \"%1\""
Save this text file as idle.reg in the Python27 folder, so you now have a file that resembles this (with your own file path, of course):
将此文本文件另存为 Python27 文件夹中的 idle.reg,因此您现在有一个类似于此的文件(当然还有您自己的文件路径):
C:\Python27\idle.reg
Right-click the idle.reg file, and in the context menu, click Merge. A couple instructions may appear or notices that require a Yes or Continue that I selected. In the end, my .py files give me the option to "Edit in IDLE" again.
右键单击 idle.reg 文件,然后在上下文菜单中单击合并。可能会出现一些说明或通知,要求我选择“是”或“继续”。最后,我的 .py 文件让我再次选择“在空闲状态下编辑”。
I hope these explanations are helpful. Big thank you to those who've solved this problem before and shared there solutions.
我希望这些解释会有所帮助。非常感谢那些以前解决过这个问题并分享了解决方案的人。
回答by Mark Ch
Most of the time when this problem occurs, people will read answers directing them into the windows registry, often unnecessarily.
大多数情况下,发生此问题时,人们会阅读将他们引导到 Windows 注册表中的答案,这通常是不必要的。
In the majority of cases, the registry key
在大多数情况下,注册表项
HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command
will already exist and have the correct value, but it will only be used by Windows shell context menu if .py files are set by default to open with python.exe.
将已经存在并具有正确的值,但如果 .py 文件默认设置为使用 python.exe 打开,它将仅被 Windows shell 上下文菜单使用。
This is the first thing to check, and solves the problem in the majority of cases:
这是首先要检查的事情,并且在大多数情况下解决了问题:
- right click on a .py file
- open with...
- choose default program...
- tick always use the selected program to open this kind of file
- choose python.exe
- 右键单击 .py 文件
- 打开用...
- 选择默认程序...
- 勾选始终使用所选程序打开此类文件
- 选择python.exe
This runs the script in a terminal, but also sets the filetype back to python.
这会在终端中运行脚本,但也会将文件类型设置回 python。
Now check the right click menu again.
现在再次检查右键菜单。
回答by Mitch
Another option would be to just open the file with the idle by choosing open with:
另一种选择是通过选择打开方式以空闲方式打开文件:
C:\Python27\ArcGIS10.3\Lib\idlelib\idle.bat
as the default program.
作为默认程序。
回答by karanrp
As click to save button to save your python code there will be Two Extensions
...1) .py
and 2) .pyw
.
当点击保存按钮保存你的python代码时,将会有Two Extensions
...1).py
和 2) .pyw
。
So for Python 2 you have to save python program using extension .pyw
.
因此,对于 Python 2,您必须使用扩展名保存 python 程序.pyw
。
回答by David
As a newer update, for people that are having the "missing idle" issue with Windows 10 using Python 3.6 (64-bit).
作为较新的更新,对于使用 Python 3.6(64 位)的 Windows 10 存在“空闲空闲”问题的人。
From my experience, this happens when you install other python editors, and you change your default app to open with that editor.
根据我的经验,当您安装其他 Python 编辑器并更改默认应用程序以使用该编辑器打开时,就会发生这种情况。
The easiest way to fix this issue is to click the "start" button, then navigate to settings --> System --> Default Apps --> "Choose default apps by file type". Scroll down till you find ".py" file type and click on the icon and choose "Python"(has a little rocket ship in the icon). This will change your default app back to "Python.exe", and the context menu "edit with idle" will appear once again on your ".py" files.
解决此问题的最简单方法是单击“开始”按钮,然后导航至设置 --> 系统 --> 默认应用程序 -->“按文件类型选择默认应用程序”。向下滚动直到找到“.py”文件类型,然后单击图标并选择“Python”(图标中有一个小火箭)。这会将您的默认应用程序更改回“Python.exe”,并且上下文菜单“edit with idle”将再次出现在您的“.py”文件中。
Hope this helps!
希望这可以帮助!
回答by osafak
I think the majority of cases are caused by the Py launcher that comes with Python 3. When you install Python 3 alongside Python 2.x, the *.py and *.pyw files are associated to run with the new Py launcher. Since *.py and *.pyw files are no longer associated with Python.exe, that breaks the "Edit with IDLE" and similar context menu options, despite all relevant registry entries being present and correct.
我认为大多数情况是由 Python 3 附带的 Py 启动器引起的。当您将 Python 3 与 Python 2.x 一起安装时,*.py 和 *.pyw 文件与新的 Py 启动器关联以运行。由于 *.py 和 *.pyw 文件不再与 Python.exe 相关联,尽管所有相关的注册表项都存在且正确,但这会破坏“使用 IDLE 编辑”和类似的上下文菜单选项。
Right clicking a file and choosing Python.exe and selecting "always use the selected program to open this kind of file" option fixes the problem (even if Python.exe seems to be already set as the default program) but then you lose the Py launcher functionality. This may well be considered a bug with the Python 3.x installer and I think should be fixed at that level by the Python developers.
右键单击文件并选择 Python.exe 并选择“始终使用所选程序打开此类文件”选项可解决问题(即使 Python.exe 似乎已设置为默认程序)但随后您丢失了 Py启动器功能。这很可能被认为是 Python 3.x 安装程序的一个错误,我认为应该由 Python 开发人员在该级别修复。
Meanwhile, I'm sure registry wizards can find a workaround for this but unfortunately, that's beyond me at the moment.
同时,我确信注册表向导可以为此找到解决方法,但不幸的是,目前这超出了我的范围。
回答by CaTx
I followed Teodorico Levoff's directions above, as well as Abyx's from the following page: https://superuser.com/questions/280636/trying-to-edit-a-python-file-but-the-edit-with-idle-has-disappeared-when-i-rig
我遵循了上面 Teodorico Levoff 的指示,以及以下页面中的 Abyx 的指示:https://superuser.com/questions/280636/trying-to-edit-a-python-file-but-the-edit-with-idle- has-disappeared-when-i-rig
However, it only works partially. When I right-click on a .py file, no 'Edit with IDLE' shows up. Choosing 'Edit' opens the file with IDLE. Also, the python icon is not associated with .py files. I decide to associate it with Notepad, then associate it with Python again. That works the magic. The icon is back, and so is the 'Edit with IDLE' option. Hope it helps.
但是,它只能部分工作。当我右键单击 .py 文件时,没有显示“使用空闲编辑”。选择“编辑”以 IDLE 打开文件。此外,python 图标与 .py 文件无关。我决定将它与记事本相关联,然后再次将其与 Python 相关联。这很神奇。图标又回来了,'Edit with IDLE' 选项也回来了。希望能帮助到你。
回答by Akash Hedau
This issue is arising because of the problem in the registry of Python installation. While one may edit the registry and resolve the issue, the simple solution for this can be:
此问题是由于 Python 安装注册表中的问题引起的。虽然可以编辑注册表并解决问题,但对此的简单解决方案可以是:
DELETE ALL THE REGISTRIESpertaining to the py extensions and
Re-install Pythonand let installation take its course of action.
删除所有与 py 扩展相关的注册表,然后
重新安装 Python并让安装进行。
The problem will definitely resolve.
问题肯定会解决。
Happy Programming
快乐编程
回答by Loshanx Aided
After uninstalling both 2.7
and 3.6
, reinstalling 3.6
, I ran the init.py ,main.py, and idle.pyw found in C:\Program Files\python\Lib\idlelib
and the edit with menu reappeared
卸载2.7
和3.6
重新安装后3.6
,我运行了init.py 、main.py 和 idle.pyw ,C:\Program Files\python\Lib\idlelib
并且重新出现了带有菜单的编辑