To debug the script in VS Code, just set a breakpoint and click Run-> Start Debugging or F5.ĪrcGIS is a great technical platform, but first you have to learn how to wade past the product managers and licence managers to get to it. IntelliSense highlighting should now work. You could define CURRENT in your environment somewhere. 'CURRENT' was not defined outside the ArcGIS window so I updated the script to reference my project file explicitly. This is because many of the examples and tutorials you will find might not have been updated for ArcGIS Pro.
Not just the language changes, but the structural changes.
It is important to be aware of the many differences between the old arcpy for Python2.7 and new arcpy for Python3. Mxd = arcpy.mp.ArcGISProject("C:/mypath/arcgisprojects/myproject.aprx") So, while most code examples I found start with: import arcpy The structure of the library was redesigned for ArcGIS Pro/Python3. The next issue you will find is that arcpy.mapping doesn't seem to exist! it was replaced with arcpy.mp. So select this in VS Code and it is now linked in to the same python environment used by ArcGIS Pro. The name of the cloned active environment is C:\mypath\arcgispro-env. Hit Ctrl-Shift-P then select option Python: Select Interpreter. In VS Code select the Python Interpreter.
Once it succeeds, activate it by selecting it in the python package manager UI.įor VS Code, install Python extension for Visual Studio Code. If cloning fails, restart ArcGIS Pro as administrator and try again. Use the integrated Git tool windows to commit and push changes to your code, manage branches, sync with your remote repositories, and resolve merge conflicts. From the new Git menu, you can create or clone repositories from GitHub or Azure DevOps. I called the clone C:\mypath\arcgispro-env. Use Git as the default source control experience in Visual Studio right out of the box. You probably want to do this in case you need to install any python conda packages that are not part of the default environment shipped with ArcGIS Pro.Ĭlick Manage Environments and clone arcgispro-p圓. In ArcGIS Pro, Under the Project menu, Open Python and clone the default environment. ArcPy is mainly used for running scripts on the desktop. Its also important to know that there is a Python API SDK and a Python Toolbox and these have different uses. VS Code is also different from Visual Studio, which is the OP's question, but most of the principles will be the same. It includes its own Conda package manager and runs Python3. ArcGIS Pro is significantly different from ArcGIS Desktop 10.x. So this might be helpful for some.įirstly, it is important to be careful with the terminology. Or you may have Visual Studio experience but not VS Code. You may be familiar with Python, but not ArcGIS 10.x or Pro. It is confusing at first as it depends where you have come from.
Here's how to get things working on Windows 10 and ArcGIS Pro 2.5.0 I had some difficulty integrating ArcPy with ArcGIS Pro and VS Code.