Running standalone python 3 script in scheduled task on ArcGIS Server

1219
1
07-15-2021 06:31 AM
MaximeDemers
Occasional Contributor III

Hi,

I would like to run standalone python 3 scripts (using arcpy) in scheduled tasks on arcgis server v10.6.1 on Windows Server 2019.

I have found an installation of python 3 in this location: C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\ and I wonder if it's ok to use it for running standalone scripts because ArcGIS Pro is not installed on that server, there is only ArcGIS Server.

Also, I have read that I have to create a new python env in order to keep the arcgispro-py3 intact. Is it ok to create a new python env in the C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs

 

Do you have any suggestions in regard with what I am trying to do?

 

Many thanks,

Maxime

0 Kudos
1 Reply
Brian_Wilson
Occasional Contributor III

You might need administrator rights to create an environment in Program Files but it really should not matter where it is as long the user running the scheduled task has permission to read the folder.

I do "conda env list" to see all the environments set up on a machine and I see this

# conda environments:
#
arcgispro-py3   * C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
arctic            C:\Users\bwilson\AppData\Local\ESRI\conda\envs\arctic
covid             C:\Users\bwilson\AppData\Local\ESRI\conda\envs\covid
dembuilder        C:\Users\bwilson\AppData\Local\ESRI\conda\envs\dembuilder
p39               C:\Users\bwilson\AppData\Local\ESRI\conda\envs\p39

Then I can use the full path to python in a script by picking any of those and adding "\python.exe" to the end for example

C:\Users\bwilson\AppData\Local\ESRI\conda\envs\arctic\python.exe --version

Python 3.7.9

Personally I avoid using "Program Files" because the space is endless pain in scripts.

You might need to set up your environment PATH variable to let you use conda.  It is in C:\Program Files\ArcGIS\Pro\bin\Python\Scripts

Another useful command once you have conda working at command line is "conda info", it will list all the env directories it knows about. (and lots of other stuff)