.py 文件的 IDLE 编辑消失了

Edit with IDLE disappeared for .py files

当我右键单击 .py 文件时,我曾经有 Edit with IDLE 选项,但我 uninstalled/reinstalled 多次让一些东西工作,现在它不见了。我在 HKEY_CLASSES_ROOTHKEY_LOCAL_MACHINE 下的注册表中检查了 Python.FilePython.NoConFile 下的值,它是 "C:\Python27\pythonw.exe" "C:\Python27\Lib\idlelib\idle.pyw" -e "%1",所以我不确定为什么它不起作用。它适用于 .pyw 个文件。有人可以帮我重新开始工作吗?我也试过修复我的 python 安装但无济于事并遵循 Python IDLE disappeared from the right click context menu

这通常是因为在文本编辑器中打开了一个 .py 文件,并且不小心将默认 "open with" 选项设置为 python 以外的选项。

尝试:

  • 右键单击 .py 文件
  • 打开...
  • 选择默认程序...
  • 勾选总是使用选择的程序打开这种文件
  • 选择python.exe

这会在终端中运行脚本,但也会将文件类型设置回 python。

现在再次检查右键菜单。

...

对于那些认为 *durr 没那么简单的人*,先试试吧 - 它可能会阻止您无缘无故地在注册表中乱搞!

这种事情可能是 Windows 版本和 Python 版本特定的,而且修复起来令人抓狂。有扩展名、抽象文件类型和可执行文件。对我来说,使用 Windows 10 和 3.5.1,assoc 命令提示符 returns 包含

的 .xyz 关联列表
.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pyw=Python.NoConFile
.pyz=Python.ArchiveFile
.pyzw=Python.NoConArchiveFile

assoc .py=Python.File 将设置关联。一旦这些设置正确,仍然存在将抽象文件类型映射到可执行命令的问题。 Mark Ch 的回答解决了这部分。

我建议我有更好的方法来解决这个问题。 右键单击 .py 文件,打开方式,选择另一个应用程序,更多应用程序并确保选中显示 'always use this app to open .py files' 的复选框,然后在这台电脑上查找另一个应用程序,一个 window 资源管理器将打开。然后选择这个文件 C:\Python34\Lib\idlelib\idle.bat 还有一件事,我不喜欢 python 文件的图标(python 徽标消失)。但是 python 文件将在 python IDLE 编辑器中打开,只需单击一下(我将鼠标设置为双击一次)。

感谢您阅读我的建议

我一直在使用 python 3.6,在安装(后来删除)python 2.7 后 运行 遇到了这个问题 (谢天谢地,我有另一台机器进行了全新安装)

恢复"Edit with IDLE"/文件图标/打开选项:

使用以下内容制作一个.reg文件,右键单击它,然后选择'merge':

(注意:"C:\WINDOWS\py.exe" 应该是正确的,但请先仔细检查 .exe 是否存在)

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.py]
@="Python.File"
"Content Type"="text/plain"

[HKEY_CLASSES_ROOT\Python.File]
@="Python File"

[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]
@="\"C:\WINDOWS\py.exe\",1"

[HKEY_CLASSES_ROOT\Python.File\Shell]

[HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle]
"MUIVerb"="&Edit with IDLE"
"Subcommands"=""

[HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle\shell]

[HKEY_CLASSES_ROOT\Python.File\Shell\open]

[HKEY_CLASSES_ROOT\Python.File\Shell\open\command]
@="\"C:\WINDOWS\py.exe\" \"%L\" %*"

[HKEY_CLASSES_ROOT\.pyw]
@="Python.NoConFile"
"Content Type"="text/plain"

[HKEY_CLASSES_ROOT\Python.NoConFile]
@="Python File (no console)"

[HKEY_CLASSES_ROOT\Python.NoConFile\DefaultIcon]
@="\"C:\WINDOWS\py.exe\",1"

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell]

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\editwithidle]
"MUIVerb"="&Edit with IDLE"
"Subcommands"=""

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\editwithidle\shell]

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open]

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open\command]
@="\"C:\WINDOWS\pyw.exe\" \"%L\" %*"

Adding/Fixing 菜单版本:

这是 IDLE 3.6 32 位的 .reg 示例,其中 █ 是安装路径(使用双\')

对于其他版本,更改 "Edit with IDLE 3.6 (32-bit)"edit36-32 以匹配您的版本

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle\shell\edit36-32]
"MUIVerb"="Edit with IDLE 3.6 (32-bit)"

[HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle\shell\edit36-32\command]
@="\"███████████████\pythonw.exe\" -m idlelib \"%L\" %*"

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\editwithidle\shell\edit36-32]
"MUIVerb"="Edit with IDLE 3.6 (32-bit)"

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\editwithidle\shell\edit36-32\command]
@="\"███████████████\pythonw.exe\" -m idlelib \"%L\" %*"

我也下载了python 3-4次,但我意识到你必须选择用python启动器打开.py文件,带有飞船的图标。

  1. 因此,右键单击 .py 文件
  2. 打开方式...
  3. 选择另一个程序
  4. 确保勾选“始终对 .py 文件使用所选程序”
  5. 使用飞船选择python程序。

这解决了我的问题,我希望它也能解决你的问题。