Anaconda, Spyder and ArcGIS PRO

20853
15
07-17-2016 01:55 AM
Labels (1)
DanPatterson_Retired
MVP Emeritus
11 15 20.9K

Anaconda ... python ... spyder ... conda .... arcgis pro

Some new info that may make it easier for 2.5

/blogs/dan_patterson/2020/02/09/clone-arcgis-pro-25 

/blogs/dan_patterson/2020/02/06/arcgis-pro-25-check-your-specs 

-------------------------------------------------

Ok... change is inevitable... at least we still have IDEs, having harkened from the card reader days.

So this is a running visual of installing Spyder so I can use with ArcGIS PRO and for general python 3.4/5/6 work

I have used pythonwin and pyscripter for some time.

Some people are charmed by pycharm and so people can't wait to be IDLE. ... but for now, I will document Spyder.

I will add to this as I find more..

NOTE See the Comments section for other sample images of Spyder

Updates:

 2017-10-31 Anaconda 5.0 is out

see the changelog for details

2017-02-18 Anaconda 4.3 is out  

see the full changelog for details...  some highlights...

  2016-10-20 Conda and ArcGIS Pro | ArcPy Café 

Things just got a whole load easier....

Current distribution supports up to and including python 3.6, and a nice new Spyder plus many more upgraded packages.  I am using this for future-proofing my work.  Arc* will eventually be there so you may as well test while you can.

-------------------------------------------------------------------------------------------------------------------------------------------------

I will leave the material below as a legacy record since much of it still applies

The original link on ArcGIS Pro and the changes to managing python environments can be found here

.... Python and ArcGIS Pro 1.3 : Conda

Related python information can also be found in

.....   The ...py... links

        Coming to Python.... preparation and anticipation

        Python 3.5 comes to iThings

Additions and modificationsDocumentation

-

-  2016-07-15  importing xlsxwriter

-  2016-07-15  initial post

  1. Anaconda | Continuum Analytics: Documentation
  2. Get started — Conda documentation
  3. Anaconda package list
  4. Excel plug-ins for Anaconda |
  5. Spyder Documentation

:------------------------------------------------------------------------------------------------------------------------:

State the obvious..... Install ArcGIS PRO 

Just follow the instructions.  Don't try and monkey-patch an old machine that barely runs ArcMap.  Start fresh.

1.  Install your Python IDE

I have never used Arc*'s built in IDE.  I am not sure why they include it, except for the fact that they can control its installation and no one needs to worry about problems associated with a separate  IDE.  I installed spyder, Jupyter Qt-console and PythonWin.  Spyder and Jupyter are included in the Anaconda distribution that esri provides.  If you don't use one now, then install spyder.

2.  Setting your default editor

 If you want to use another one, go to the Project pane, the Geoprocessing Options and do some setup.  Spyder is located in a somewhat cryptic folder path, which I have show in navigation mode and in step 2. as a visual with cutouts for the fiddle bits.  In reality, the portion of the path C:\Program Files\ArcGIS\Pro is the default installation path and the one most likely to be offered during installation and for multi-user machines.  I personally install mine where I know what it is in the folder.... C:\ArcPro.

spyder_01.png

:------------------------------------------------------------------------------------------------------------------------:

3. The file path to locate the executable

I assume a default path installation in the following.  Everything prior to the ...\bin folder is specific to your machine install path.

spyder_02.png

:------------------------------------------------------------------------------------------------------------------------:

4. The site-package folder

What is included without by default from an ArcGIS Pro installation... this is not a complete list of available packages... the list of those, is given above in the table.  The packages come by python version.  We are currently using python 3.4.x in ArcGIS PRO and ArcMap

spyder_03.png

:------------------------------------------------------------------------------------------------------------------------:

5. The Spyder folder contents

What is in the spyder folder... scientific_startup does some standard imports for what-it-says-type work

spyder_04.png

:------------------------------------------------------------------------------------------------------------------------:

6. The pkgs folder

A record of the packages that were installed.

spyder_05.png

:------------------------------------------------------------------------------------------------------------------------:

7.  Importing packages... xlsxwriter demo

Here is the workflow I used to import the xlsxwriter module for use in python and arcmap (presumably).

Here is the workflow I used to import the xlsxwriter module for use in python and arcmap (presumably).

From the start button (windows 10, bottom left) navigate to the ArcGIS folder via All Apps find the Python Command Prompt and right-click on it and Run as Administrator

xlsxwriter1.png

Do the conda install xlswriter entry as suggested in the originating post.

xlsxwriter2.png

Hit Enter and away you go. The magic happens and it should be installed.

xlsxwriter3.png

At this stage, I went back to Spyder and from the IPython console I tested... looks good

xlsxwriter4.png

:------------------------------------------------------------------------------------------------------------------------:

More as I find it...

15 Comments
XanderBakker
Esri Esteemed Contributor

Thanks for sharing Dan. Will start with ArcGIS Python API soon!

DanPatterson_Retired
MVP Emeritus

Yes... I noticed that distraction as well ... sigh

XanderBakker
Esri Esteemed Contributor

Too many distractions, no to for sleep these days... will post another blog on including the influence of wind on the movement of the overhead power lines and create the 3D lines with the maximum movement sideways...

Daniel_ItzamnaAvila_Ortega
New Contributor

Hi,

I am new in this Python, Anaconda, Spyder environment, but I have been reading some posts without further success, I have even managed to do what is written here: arcgis desktop - How to get arcpy to work with Anaconda? - Geographic Information Systems Stack Exch... 

The thing is that I want to use all ArcMap commands or tools, particularly union, in Spyder. I want to do this because I have a very large file which just crashes in ArcMap and the Python shell everytime I want to do the process.

I would be very thankful to whoever helps me with this.

DanPatterson_Retired
MVP Emeritus

You should open up a question in the https://community.esri.com/community/developers/gis-developers/python?sr=search&searchId=efb2137f-11...‌ and show the details of what you have done there.  If you have managed to create the appropriate environment then getting started is as simple as firing up Spyder and typing "import arcpy" in the IPython window.

DuncanHornby
MVP Notable Contributor

Just a comment to people who have come to this blog and are new to using python in the spyder IDE (such as myself). In ArcGIS Pro 2.0.1 I had to go to the  Python option > Add Packages and install spyder first before I could follow your instructions.

NeilAyres
MVP Alum

Dan Dan_Patterson followed your links to this post from Duncan.

Probably a dumb question, so what is Spyder? Is it an IDE where you can develop, save and run python scripts or is it another python package?

DanPatterson_Retired
MVP Emeritus

The only thing it lacks is code-folding (which I miss from pythonwin), but it is coming in version 4.

Gaze intently on this image...

  • multiple script viewed in tabs
  • to the right top... Variable explorer, File Explorer, online Help (tab currently selected), Profiler, Static Code Analysis plus a few I haven't enabled
  • bottom right an IPython console for the 'interactive-you', plus you can have several consoles running
  • bottom bottom = History log... you can set the length of your history (lots and lots) and it saves code lines between sessions (ps, the got rid of the python console
  • a configurable toolset

Here is the file explorer as an example

Need a quick Matplotlib graph/?? no problem

I could go on, but it is a great program and there is loads more that I haven't even covered, like organizing your code into tasks, GitHub support etc.

Dan

by Anonymous User
Not applicable

So can Pyscripter not be used against arcpy 64-bit (ArcGIS Pro) then? It is just me or did getting python running against Pro become confusing and anything but straightforward. 

DanPatterson_Retired
MVP Emeritus

I used to use pyscripter (amongst many other IDE's over the years), but I was intrigued that spyder, ipython and jupyter were included in anaconda distributions.  So I tried them and find that they are indeed excellent packages.  pyscripter development was on hiatus for several years and only got revitalized recently so I was looking at what was recommended within the anaconda distribution.  I you don't want to change ide's then stick it out.  I am not adverse to using multiple ide even at the same time while working.  I am not adverse to change and I really like what I see and I am glad I switched.  As for esri... they don't really mention anything else but using the builtin python interpreter within Pro.  That has to be the worst interface to python that I have ever seen.  

So if you have to have pyscripter, get it to work.

If you want to try something new and IMHO... better, then give Spyder, Jupyter QT-console and Jupyter Notebooks a whirl

by Anonymous User
Not applicable

I am open to change as well, but I am having a really hard time finding information on how and if pyscripter works with arcpy 64-bit. I am having no luck at all. It also seems confusing and not straightforward that we have to also install anaconda to get python and GIS working together? I am attempting to run the anaconda install from Pro's python interface, however nothing happens. No errors, spins momentarily then stops and I don't see it listed under "installed". Shouldn't all this come pre-installed with Pro as without jumping through these extra hoops no one can use arcpy outside of GIS itself. Seems like the setup of python got way more involved with Pro. I am also unclear, again having trouble finding information, if I am missing setup steps in pyscripter itself such as setting the path. Experimented some, but wasn't fully sucessful. I have the latest version of Python (64-bit), pyscripter (64-bit), and ArcGIS Pro running all the latest updates.

DanPatterson_Retired
MVP Emeritus

You shouldn't do a separate install of python for sure.  The version of python that has to be used is the one that is within the anaconda distribution.  installations of software are either done from the packages distributed, but not installed, from the Project-Python link (aka the left arrow at the top left of the screen) or by using the proenv.bat file.  you can pip install some packages and they behave nicely.  You might want to search 'pyscripter' on geonet to see if anyone got it working with Pro.  I didn't even bother,.

KimOllivier
Occasional Contributor III

The latest 64 bit version of Pyscripter 3.6 does now handle conda environments. This saves you having to switch IDEs.

It does interfere with Pyscripter32 even though they install in different places. But you can edit and run most scripts with the 64 bit version anyway. https://sourceforge.net/projects/pyscripter/

curtvprice
MVP Esteemed Contributor

These instructions require that you have write access to the Program Files folder. This is not the case for a lot of people that work for large organizations. Fortunately, Esri has been working on their interface in Pro to manage Anaconda environments. If you are pretty much working just in Pro, you can use Pro's Python package manager instead of Navigator. If you clone your environment as a regular user in this environment, it will create an Anaconda environment in your user folder that you have complete access to modify. 

This was set up so it works with regular users a few versions back and it has been improving.

Screen capture of Spyder install in ArcGIS Pro Python Package Manager

DanPatterson_Retired
MVP Emeritus

some updates since this is 4 years old

/blogs/dan_patterson/2020/02/09/clone-arcgis-pro-25 

About the Author
Retired Geomatics Instructor at Carleton University. I am a forum MVP and Moderator. Current interests focus on python-based integration in GIS. See... Py... blog, my GeoNet blog...
Labels