Published on

How to Set Up Visual Studio Code for Use With ArcGIS Pro

This article teaches you how to set up Visual Studio Code for use with ArcGIS Pro, ArcPy and ArcGIS API for Python.

Table of Contents

Installation

If you don't have Visual Studio Code (VS Code for short) yet, download and install it. When installing, you can accept the default settings.

For any Python development, you should install the Python and Pylance extensions by Microsoft. There are also extensions for Jupyter Notebooks if you'd want to use VS Code for writing notebooks. Follow these instructions for installing extensions:

  1. Open the Extensions view on the side:
Extensions view location
  1. Search for Python extension by Microsoft and click the green Install button:
Python extension installation

The Pylance extension is automatically installed together with the Python extension.

Setup for all files and projects

If you want to configure ArcGIS Python environment globally for every folder and Python file you will open, use the following instructions:

  1. Select File -> Preferences -> Settings (or Ctrl+,) to open the Settings editor in VS Code.
  2. Make sure that the User tab is selected and type Python: Default Interpreter Path in the search bar. This will make the editor only show settings matching your search.
  3. Insert C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exeinto the Python: Default Interpreter Path input field:
Python interpeter configuration

That's it. The settings are saved automatically.

With this configuration, you are pointing to your ArcGIS Pro Python interpreter location. If there is no python.exe file in this location, yours may be located at C:\Users\YOUR_USER_NAME\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe(make sure to replace YOUR_USER_NAME with your actual user name). You can also find your Python path in ArcGIS Pro from the Project (Settings) menu under Python tab:

Python path location

Setup for a single project

If you want to configure ArcGIS Python environment for a single project only, use these instructions:

  1. Select File -> Open Folder (or Ctrl+K, Ctrl+O) to open your project folder.
  2. Select File -> Preferences -> Settings (or Ctrl+,) to open the Settings editor in VS Code.
  3. Select the Workspace tab and type Python: Default Interpreter Path in the search bar. This will make the editor only show settings matching your search.
  4. Insert C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exeinto the Python: Default Interpreter Path input field:
Python interpeter configuration

That's it. The settings are saved automatically.

With this configuration, you are pointing to your ArcGIS Pro Python interpreter location. If there is no python.exe file in this location, yours may be located at C:\Users\YOUR_USER_NAME\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe(make sure to replace YOUR_USER_NAME with your actual user name). You can also find your Python path in ArcGIS Pro from the Project (Settings) menu under Python tab:

Python path location

Seeing Visual Studio Code in action

With the Python interpreter properly configured, VS Code becomes a powerful tool for GIS scripting. It provides code completion, documentation for all the available tools, linting, debugging and much more.

Importing ArcGIS Python modules
Autocomplete for ArcGIS Python tools
Documentation for ArcGIS tools