[934] Run the python file directly (ArcGIS Pro)

发布时间 2023-11-03 11:10:43作者: McDelfino

ref: The Edit with IDLE and Run with ArcGIS Pro options are not available in the context menu when right-clicking Python files


Description

In some instances, when right-clicking Python files, the 'Edit with IDLE' and 'Run with ArcGIS Pro' options are not available in the context menu.

Image of the the Edit with IDLE and Run with ArcGIS Pro options are not available in the context menu

Cause

The following are the possible causes:

  • The default app to open the Python files has changed.
  • The registry keys are not available.

Solution or Workaround

Select one of the options below depending on the cause to resolve the issue.

Select python.exe as the default application to open Python files

  1. Right-click the Python file, and select Properties.
  2. In the Properties window, click the General tab, and click the Change button next to Opens with:.
  3. In the Open with window, click the Browse button.
  4. In the Open with… window, paste the following path in the address bar, and press Enter.
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
  1. Select python.exe, and click Open.
Image of the Open with... window
  1. Close the Properties window.

Add the registry keys

Warning:   
The instructions below include making changes to essential parts of the operating system. Esri recommends performing a backup of the operating system and files, including the registry, before proceeding. Esri cannot guarantee results from incorrect modifications while following these instructions. Exercise caution. Consult a qualified computer system professional if necessary.
Note:
Replace Python27 and ArcGIS10.7 with the appropriate versions if needed.
  1. Open a text editor such as Notepad, and copy the following command to the text editor:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command]
@="\"C:\\Python27\\ArcGIS10.7\\pythonw.exe\" \"C:\\Python27\\ArcGIS10.7\\Lib\\idlelib\\idle.pyw\" -e \"%1\""

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Edit with IDLE\command]
@="\"C:\\Python27\\ArcGIS10.7\\pythonw.exe\" \"C:\\Python27\\ArcGIS10.7\\Lib\\idlelib\\idle.pyw\" -e \"%1\""
  1. Save the file as a .reg file in the Python folder. In this example, the file is saved in the Python27 folder. By default, the location is as follows:
C:\Python27
  1. Right-click the .reg file, and click Merge. Proceed to click Yes when prompted.

The following image displays the availability of Edit with IDLEEdit with IDLE (ArcGIS Pro), and Run with ArcGIS Pro options in the context menu.

Image of the Edit with IDLE and Run with ArcGIS Pro options are available in the context menu