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.


7 Answers 7


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.

  • 1
    PolyGeo where is the Desktop10.2.2.pth file. exist? i can't find it
    – newGIS
    Commented Apr 14, 2021 at 16:38
  • @newGIS I've never needed to do this personally. My answer came from the documentation. Nevertheless, I've updated my answer with a link to later documentation.
    – PolyGeo
    Commented Apr 15, 2021 at 9:08

@PolyGeo's solution is top-notch, but not perfect for every use case.

For example, in my use case, I had a Python 2.7.11 install on my machine and then I installed ArcGIS which came with Python 2.7.8. When I followed the instructions at Importing ArcPy, I found that the path C:\Python27\ArcGIS10.3\Lib\site-packages had a file called Desktop10.3.pth in it with the following lines:

C:\Program Files (x86)\ArcGIS\Desktop10.3\bin
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolBox\Scripts

Yet, I still could not get ArcPy to import w/o error. I found that this is because the Python path being used by my machine is the 2.7.11 path, rather than the 2.7.8 path (the ArcGIS-specific Python install). Even if you include the correct path inside your Windows Environment Variables, it will not work because when you type python into the Command Line Interface, Windows does not know which Python install to use.

This is my work-around:

  1. Navigate to C:\Python27. You should see a folder called ArcGIS10.3 or whichever version you have installed.

  2. Click into ArcGIS10.3 and locate the Python.exe executable. Copy/paste this exe and rename it arcpy or something else that you can remember.

  3. Make sure you have added the C:\Python27\ArcGIS10.3 directory into your path in your Windows Environment Variables.

  4. Open a new cmd and type the name you used (i.e. arcpy). You should see a Python interpreter open up and you should see the correct version 2.7.8. If this is all correct, try typing import arcpy into the interpreter. If it works, you have been successful!


This problem happens for me because the path of ArcGIS was in Program File(x86) instead of normal place(program file). there are two methods to fix the problem:

  1. you can change the path of python for example by PyScripter (it has a function to change the path) or

  2. the easiest way is: change the name of python27's folder to python27_old. in control panel click on program and feature, choose uninstall/change and repair ArcGIS. it will install python again with correct path. It worked for me.


I had a similar problem, and had tried all the suggested solutions on this page (and others) in vain. The problem was that 'C:\Python27' was listed above 'C:\Python27\ArcGIS10.4' under PATH in Environment Variables. It was resolved once I switched the order of the two, so now any python execution first goes through the python.exe file inside the ArcGIS10.4 sub-directory. I hope this helps.


I just got off the phone with esri and the issue for me was resolved by launching jupyter notebook from the proenv.bat file which is a command line space. k This file is located at C:\Program Files\ArcGIS\Pro\bin\Python\Scripts On the proevn.bat file right click> Run as Administrator. Then you can launch jupyter notebook by typing jupyter notebook. Make sure you are in the correct file path space before typing jupyter notebook to launch it.
Note this is assuming you have jupyter installed by running conda install ipython-notebook.


My solve was rather brutal I recently installed ArcGIS10.5, but the system still included a ArcGIS10.2 python folder to which everything was directed. Removing those folders and re-installing my Python IDE (pyscripter) solved the issue!


I had the .pth file as described by Blairg23. I finally resolved the problem by replacing the upper case 'A' in the line 'C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy' with a lowercase 'a' to match the destination path

Not the answer you're looking for? Browse other questions tagged or ask your own question.