Institute for Geographic Information Science San Francisco State University

Using Spyder with ArcGIS Pro 2.3.3

Section 1: Spyder and ArcGIS Pro for HOME USE (Start here if you are working on your own computer (for HSS lab computers, skip to Section 2)

Spyder is the “Scientific Python Development Environment.” It is an integrated development environment (IDE) for programming written in Python, for Python, and designed by and for scientists, engineers, and data analysts: https://www.spyder-ide.org/ If you’re reading this guide, which is provided by SF State’s IGISc, you’re likely using Spyder with ArcGIS Pro. If that’s the case, keep in mind that In the ArcGIS world, because we're in this transition phase between ArcMap, which uses Python 2.7, and ArcGIS Pro, Python 3.x, 's solution was to use virtual environments in order to not break most of our C:\python27 installs. There is an open source package management system that helps manage virtual environments called "conda". Conda is automatically installed when you install ArcGIS Pro. Not to be confused with "Anaconda", which is a standalone scientific package management system, based on conda. So in short, we recommend that you first download/install ArcGIS Pro, which will come with the “conda” package from which you can install Spyder.

Download and Install ArcGIS Pro 1. For instructions how to download and install ArcGIS Pro, visit: http://gis.sfsu.edu/arcgis-pro a. Note that if you have a previous version of ArcGIS Pro already installed on your computer, you may need to follow ESRI guides that will help you clear out ArcGIS Pro from a system that cannot fully uninstall the : https://esribelux.com/helpdeskitem/clean-uninstall-of-arcgis-pro/

2. Once you have ArcGIS Pro installed, open ArcGIS Pro and choose PythonManage EnvironmentsClone Default (this may take several minutes)

1

3. Check the new cloned environment bubble and choose OK

4. Restart ArcGIS Pro so the changes to your environment are saved (confirm that arcgispro- py3-clone is set in the ArcPro Project Environment when you reopen Pro)

2

5. Type Python Command Prompt into your Start Menu (you don’t want Python Command Line, which will likely be the first option that pops up as you start typing into the Start Menu) a. *Note that on a home computer you may need to right-click on Python Command Prompt and Run as Administrator* Install Spyder in the cloned ArcGIS Pro Environment

6. The Python Command Prompt window will open and will look similar to the screenshot below except that it may not have (arcgispro-py3-clone) at the beginning yet:

7. Type conda update python 8. Type conda install spyder

3

9. You’ll see a series of packages being installed (Appendix A shows the expected series of packages we have observed on the lab computers, this may differ on your home computer) 10. If all packages are installed successfully into the cloned environment when you open the Python Command Prompt it should now show the following:

(arcgispro-py3-clone) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-clone>

11. There are two ways to launch the Spyder IDE: a. In Python Command Prompt, type spyder b. OR search for the spyder application in the Start Menu

12. The Spyder IDE should open and is ready for you to start coding with Python:

Set Spyder as the default script editor in ArcGIS Pro 13. Once you have installed spyder in the cloned ArcGIS Pro environment, you’ll want to make spyder the default script editor in Pro. Open Pro and go to the Project tabOptionsGeoprocessing.

4

14. Enter the path to the spyder.exe application (if you don’t remember where it was installed, check where the clone was installed in ArcGIS ProSettingsManage Environments

15. What you enter for your script editor should look something like the following screenshot except you won’t have the 9-digit ID part for a home computer

16. Choose OK and Restart ArcGIS Pro 17. Confirm that ArcGIS Pro has retained spyder.exe as the default script editor when you reopen

5

Section 2: Spyder and ArcGIS Pro in HSS 272 & 290 computer labs

1. Open ArcGIS Pro 2. Choose PythonManage Environments

6

3. Choose Add 4. Select the pre-created environment called arcgispro-py3-Spyder that has been created for you on the C:\ drive (make sure you’re choosing the SECOND arcgispro-py3-Spyder folder)

5. You should be able to check the bubble beside it once you have successfully added it

7

6. Set the default script editor in ArcGIS Pro (choose OptionsGeoprocessing) to C:\arcgispro-py3-Spyder\arcgispro-py3-Spyder\Scripts\spyder.exe

8

7. Now Pro will default to using Spyder as the default script editor

8. Outside of the ArcPro interface, there are two ways to launch the Spyder IDE from your cloned environment: a. In Python Command Prompt, type spyder b. OR search for the spyder application in the Start Menu 9. The IDE should look something like the following:

9

More Spyder resources

Pristine arcgispro-py3 https://community.esri.com/docs/DOC-12021-python-at-arcgispro-22

Python Package Manager and Working with Python environments https://pro.arcgis.com/en/pro-app/arcpy/get-started/what-is-conda.htm

More about virtual environments: https://realpython.com/python-virtual-environments-a-primer/

10