PyCharm is a very useful Integrated Development Environment maintained by JetBrains that has become very popular for users wanting to develop Python for use with ArcGIS Pro. This document is an attempt to guide you to a trouble free installation set up for use with ArcGIS Pro (and ArcMap if you need to work in that environment as well).
PyCharm download and install
PyCharm Community Edition is free to download from www.jetbrains.com. The Community Edition has pretty much all you will need, the professional ($) edition is worth looking into if you need to code in JavaScript or SQL, it has many useful features for that kind of development. But for coding Python scripts, the free community edition is fine.
When you run the installer be sure not to click any of the boxes on the setup dialog, it's best to keep your Windows paths and settings "clean", to avoid messing with Windows settings on which other applications may be dependent. We will be setting preferences within PyCharm to make it play well with ArcGIS.
Configure Python interpreter for ArcGIS Pro
After PyCharm launches, click the gear at the upper right corner of the screen (or press Ctrl-Alt-S) to open the settings dialog. You can set up PyCharm with multiple Python interpreters, and we want to make the default setup for ArcGIS Pro (you can choose others though, which is handy!)
- Select Python Interpreter at left
- Click the gear icon at upper right and select Add
- Select the Existing environment radio button
- Click (set) Make available to all projects
- For Interpreter: click the ... icon at right and navigate to and select the python.exe for Pro:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\argispro-py3\python.exe - Click OK.
Configure Python interpreters for ArcMap (ArcGIS 10.x).
Note this step is not needed if you aren't using ArcMap.
Repeat the steps from the last section to add the pythons for ArcMap:
- ArcMap 32-bit: C:\Python27\ArcGIS10.8\python.exe
- ArcMap 64-bit geoprocessing (if installed): C:\Python27\ArcGISx6410.8\python.exe
Now, when setting up a new PyCharm project, you can choose from the configured interpreters to get the environment you need for your project.
Configure PyCharm Terminal for ArcGIS Pro
PyCharm supports a terminal window for use in manipulating the conda environment, running shell tools, editors, or whatever else. The standard shell environment for ArcGIS Pro is the one you launch by with the Windows shortcut Python Command Prompt - which launches a shell with the proenv.bat script.
Bring up to the same settings dialog used above to set the Python interpreters
At left, find Tools > Terminal
For Shell Path: click the ... icon at right and navigate to and select
C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat
Configuring PyCharm Terminal for ArcMap
(Thank you @AzinSharaf (see comments below). An Anaconda solution may be possible as well.)
1. Create a clone of the environment Python 2.7 x64 environment
C:\Python27\ArcGISx6410.8\python.exe -m virtualenv py27-clone-108
2. Copy ArcMap .pth files from C:\Python27\ArcGISx6410.8\ folder to the py27-clone-108 venv folder
3. For Terminal use this command to start a cmd.exe with the paths in place to run and manage python modules
C:\Windows\System32\cmd.exe /k "C:\Python27\envs\py27-clone-1081\Scripts\activate.bat"