使用 Windows 10 缺少 IDLE 進行編輯

使用 Windows 10 缺少 IDLE 進行編輯

我安裝了Python 3.6.1 Windows 64位元。但是當我使用右鍵單擊時,我的空閒編輯丟失了。有人可以幫忙嗎?我已經重新安裝了幾次了,但問題仍然存在。 =(

答案1

我不知道您的上下文選單項目去了哪裡,但您可以按照此處的步驟修復它們上下文選單中缺少「使用 IDLE 編輯」選項不過,只有當您願意擺弄註冊表時才這樣做。

我沒有 Windows 電腦來嘗試此操作,但您的另一個選擇是重新安裝 Python 並尋找安裝上下文功能表/shell 擴充功能的選項。它可能就在那裡,預設情況下處於關閉狀態。

答案2

該問題很可能源自於Python.File使用者選擇如何開啟文件來覆蓋文件類型。我可以使用 Windows 的登錄編輯器(Win+R,然後輸入regedit並按 Enter)在我的系統上修復它,如下所示:

  1. 刪除註冊表中的 所有使用者選擇條目.py,例如很可能有一個條目.pywHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice
  2. 更正/擴展這兩個條目如下

對於.py文件:

    [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"

    [HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle\command]
    @="\"C:\\python3\\pythonw.exe\" -m idlelib \"%L\" %*"

    [HKEY_CLASSES_ROOT\Python.File\Shell\open]

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

對於.pyw文件:

    [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"

    [HKEY_CLASSES_ROOT\Python.NoConFile\Shell\editwithidle\command]
    @="\"C:\\python3\\pythonw.exe\" -m idlelib \"%L\" %*"

    [HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open]

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

然後,每當您右鍵單擊檔案總管中的檔案.py或檔案時,您應該會看到一個工作選項「使用 IDLE 編輯」。.pyw雙擊或開啟檔案涉及python啟動器並直接啟動程式。

答案3

您可以在 IDLE 中開啟該文件,只需按一下滑鼠右鍵或雙擊該文件即可「開啟」。想法就在這裡, https://www.webucator.com/how-to/how-make-idle-the-default-editor-for-python-files-on-windows.cfm

  1. 開啟包含 Python 檔案的資料夾。
  2. 右鍵點選任意 Python 檔案。
  3. 選擇屬性。
  4. 在“開啟方式”部分旁邊,按一下“變更”按鈕
  5. 您可能需要選擇更多應用程式
  6. 點擊“在此電腦上尋找另一個應用程式”
  7. 導覽至安裝 Python 的位置。對我來說,這是 C 碟上的 Python37 資料夾。
  8. 開放函式庫
  9. 打開空閒庫
  10. 選擇idle.bat 檔案。
  11. 選取“始終使用此應用程式開啟...”
  12. 按一下“開啟”。
  13. 按一下“確定”關閉“屬性”。

現在,您只需雙擊 .py 檔案即可在 IDLE 中開啟它們。

答案4

如果您嘗試了上述步驟但不起作用,請嘗試以下操作(感謝 Eryk):https://bugs.python.org/issue29014

我猜想本機機器金鑰中的 SystemFileAssociations 與此有關。從他的回答複製:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle]
"MUIVerb"="&Edit with IDLE"
"Subcommands"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell\edit35]
"MUIVerb"="Edit with IDLE 3.5 (64-bit)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell\edit35\command]
@="\"C:\\Program Files\\Python35\\pythonw.exe\" -m idlelib \"%1\" %*"

相關內容