14

How would I setup PyCharm to recognize import arcpy?

I'd like to use PyCharm to develop and debug geoprocessing tool.

1

5 Answers 5

14

theJones is correct, close all your projects and go to the program settings and search for Python Interpreters. Then select C:\Python26\ArcGIS10.0\python.exe and it should automatically add arcpy for you.

Pycharm Settings

1
  • This is still valid in 2022 as I changed the Python Interpreter path in VSCode to "C:\Python27\ArcGIS10.8\python.exe," and the IDE recognized the Arcpy keyword. Commented Jun 1, 2022 at 10:43
10

To follow theJones and user5584, PyCharm 4 now stores the setting under "Project Interpreter" rather than "Python Interpreters."

With all projects closed, and PyCharm still open, go to "Configure" and then "Settings". "Project Interpreter" is under the "Default Project" menu on the left.

Click the settings gear in the upper-right, and then "Add Local." Navigate to C:\Python27\ArcGIS10.2\python.exe (or appropriate path for your version).

Hit Apply and you should have it. There may have been one more step to load or enable something at the bottom of the window, but I can't get that message to appear again and it didn't require anything but clicking on it.

Indexing took a couple minutes on a Python script I opened, and then code completion worked great.

screenshot of PyCharm settings

2
  • 1
    I have tried to add arcpy to PyCharm using above instructions but it is still not working. Pycharm is throwing an error: ImportError: No module named arcpy. Is it possible it has anything to do with python or PyCharm installation (32 vs 64bits)?
    – GeoMeteoMe
    Commented Apr 26, 2018 at 12:21
  • 1
    I encountered the same issue as @GeoMeteoMe (PyCharm v2018.4) and resolved it when I realized that the "New Project" dialog wasn't automatically selecting the environment that I'd made. It's not readily apparent since that selection is collapsed by default. Once I expanded it, selected "Existing Interpreter" rather than "New environment using...", PyCharm offered me ArcIntellisense and ArcAutoComplete. Commented Nov 23, 2018 at 20:58
7

A lot has changed since the recent update hence answering this to align with the PyCharm version 2018 interface:

  1. Close all the projects by selecting File>Close projects
  2. Select Configure gear icon>Settings

enter image description here

  1. Select Project Interpreter and click on another gear icon next to Project Interpreter dropdown and select 'Add'

enter image description here

  1. Select 'existing environment' and locate python.exe under Python27 in C drive

enter image description here

  1. Select Apply and Ok.

It will take some time to index and if it gives an error that 'No interpreter was detected' on opening a project then select File>Settings>Project Interpreter>Select Python 2.7 from the dropdown you recently assigned.

1
  • Thanks, @Deb. That worked for me
    – AbdulAziz
    Commented Jul 26, 2021 at 11:22
5

You can do this in the project Structure setting. Just add it as an sdk and it should work. I use intelliJ but pycharm should be the same.

PyCharmDocs

Add this (Use your path) for the sdk path C:\Python26\ArcGIS10.0\python.exe

Give it a name and you should be good. Adding it as a global sdk you should be done and get the code completion.

0

If you want to see Quick documentation and External Documentation from PyCharm (version 2016.2.1) then:

  1. You need to run Module docs (under ArcGIS > Python 2.7) folder first,

  2. add the following entry under File > Settings > Tools > Python external documentation

module name: arcpy

URL/Path pattern: http://localhost:7464/{module.name}.html#-{function.name}

  1. Position your cursor at the end of the function e.g. mapping.MoveLayer and press Shift + F1

  2. Your web browser should open with the following URL http://localhost:7464/arcpy.mapping.html#-MoveLayer

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