- 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:
- Open the
Extensions
view on the side:
- Search for
Python
extension by Microsoft and click the greenInstall
button:
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:
- Select
File
->Preferences
->Settings
(orCtrl
+,
) to open the Settings editor in VS Code. - Make sure that the
User
tab is selected and typePython: Default Interpreter Path
in the search bar. This will make the editor only show settings matching your search. - Insert C:\Program Files
\ArcGIS \Pro \bin \Python \envs \arcgispro-py3 \python.exeinto the Python: Default Interpreter Path
input field:
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:\UsersYOUR_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:
Setup for a single project
If you want to configure ArcGIS Python environment for a single project only, use these instructions:
- Select
File
->Open Folder
(orCtrl
+K
,Ctrl
+O
) to open your project folder. - Select
File
->Preferences
->Settings
(orCtrl
+,
) to open the Settings editor in VS Code. - Select the
Workspace
tab and typePython: Default Interpreter Path
in the search bar. This will make the editor only show settings matching your search. - Insert C:\Program Files
\ArcGIS \Pro \bin \Python \envs \arcgispro-py3 \python.exeinto the Python: Default Interpreter Path
input field:
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:\UsersYOUR_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:
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.