Set Spyder as default Script Editor

1064
3
05-09-2022 01:10 PM
dazu
by
New Contributor II

Hi there!

Could somebody indicate to me how to reference a Spyder installation located in a separate Conda environment in ArcGIS' options such that it acts as default Script Editor?

I tried to reference

  • the executable directly pasting C:\tools\Anaconda3\envs\spyder-env\Scripts\spyder.exe (this does not launch the program via cmd either)
  • the spyder-script.py by pasting "C:\tools\Anaconda3\envs\spyder-env\pythonw.exe" "C:\tools\Anaconda3\envs\spyder-env\Scripts\spyder-script.py" (this allows to open an arbitrary script from the cmd)

to the field under Project > Options > Geoprocessing > Script Editor without success.

In advance, thank you for your advice.

I am using ArcGIS Pro 2.9.2 (with a clone of the default python environment) and Spyder 5.1.5 (in a separate environment).

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Desktop shortcut

Target :
      C:\arc_pro\bin\Python\envs\arcgispro-py3\pythonw.exe "C:\arc_pro\bin\Python\envs\arcgispro-py3\Scripts\spyder-script.py"

Start in:
    C:\arc_pro\bin\Python\envs\arcgispro-py3\Scripts

 

Project, Options, Geoprocessing, Script Editor

C:\arc_pro\bin\Python\envs\arcgispro-py3\pythonw.exe "C:\arc_pro\bin\Python\envs\arcgispro-py3\Scripts\spyder-script.py"

 

Now just replace arc_pro to your clone folder  assuming ...\bin\Python\envs\arcgispro-py3 ... will need to be edited as well with your clone name

Also, within spyder make sure you are point the editor to the correct python in your path(s)


... sort of retired...
0 Kudos
dazu
by
New Contributor II

Thank you, @DanPatterson, for your answer. 

I had come across your blog posts from previous years related to this topic and tried to apply the suggestions stipulated there (i.e. second bullet from my initial post, or your answer to it). Unfortunately, it does not work. I suppose it is due to the fact that spyder does not reside in the same conda environment arcgis uses...

C:\tools\Anaconda3\envs\
- arcgis-env
- spyder-env

Calling the following .bat file from the cmd I can open an arbitrary script from ArcGIS temp folder, however, setting this as default script editor does not work. What happens upon right-click on a script tool in ArcGIS, i.e. how is the script passed to the file specified under the specified script editor?

@ECHO off

SET script=%1
call C:\tools\Anaconda3\Scripts\activate.bat C:\tools\Anaconda3\envs\spyder-env
cd C:\Users\Workstation\AppData\Local\Temp\ArcGISProTemp15984
spyder %script%

0 Kudos
DanPatterson
MVP Esteemed Contributor

You have to set spyder to use python in the arcgis-env.  It is discussed in their help topics

Installation Guide — Spyder 5 documentation (spyder-ide.org)

and there is nothing stopping you from installing spyder in Pro's environment

>>> conda install spyder=5.1.5 --no-pin


... sort of retired...
0 Kudos