ArcPy – Debugging ImportError: No Module Named Arcpy

arcgis-10.2arcpyidleinstallation

I have written a script and am trying to run it in Python IDLE 2.7.6.

I first try to import arcpy, but I get an error message saying:

ImportError: No module named arcpy

Why does it not work?

I am using ArcGIS Desktop 10.2.

Best Answer

This error is discussed near the bottom of the Importing ArcPy documentation page where there are some additional notes about ArcGIS 10.2.x (if that is the version that you are using):

Tip: If importing ArcPy produces either of the following errors, the required modules could not be found:

  • ImportError: No module named arcpy
  • ImportError: No module named arcgisscripting

To address this, browse using Windows Explorer to the python27\Lib\site-packages folder and add or edit the Desktop10.2.2.pth file. The file should contain the three lines shown below (corrected to your system's path if they do not match):


c:\Program Files\ArcGIS\Desktop10.2.2\arcpy
c:\Program Files\ArcGIS\Desktop10.2.2\bin
c:\Program Files\ArcGIS\Desktop10.2.2\ArcToolbox\Scripts

From ArcGIS 10.3.x to 10.8.x (see Importing ArcPy for those versions) it looks like:

The installation will also add the file Desktop10.3.pth (or Engine10.3.pth or Server10.3.pth) into python27\Lib\site-packages.