Select to view content in your preferred language

Can I run a python script I made in model builder in ArcMap 10.7 on ArcGIS Server 10.8.1?

2279
6
06-02-2021 09:35 AM
MichaelBouvet
Regular Contributor

I created a python script in model builder in ArcGIS Pro and tried to run it on ArcGIS Server 10.8.1, only to find out Server only uses Python 2.7 and Pro outputs the script in 3. 

I am considering attempting to recreate the script in ArcMap 10.7 model builder to get around this problem since I read that ArcMap outputs to 2.7.x. 

I am just wondering if my theory is true? 

Thank you in advance!

Michael 

0 Kudos
6 Replies
simoxu
by MVP Regular Contributor
MVP Regular Contributor

ArcGIS Server has a "hidden" python 3 environment, that's why you can publish web tools to it from ArcGIS Pro. but this python 3 environment does not include all the packages you have in the ArcGIS Pro Python environment.  You can think this is a stripped down version of the python environment coming with your ArcGIS Pro.... 

How did you run your script in ArcGIS Server? if you tried sharing a web tool from ArcGIS Pro and it did not work, then I guess some packages you are using in your script are missing in the ArcGIS Server Python 3 environment.

If you could achieve the same function in ArcMap, definitely try ArcMap, as the 2.7.x environment is default environment for ArcGIS Server 10.8.x, you'll have a better chance. 

Good luck

MichaelBouvet
Regular Contributor

That's super interesting about the "hidden" python environment. 

I am running the .py script I created from ArcMap through a .bat file that calls the python.exe and uses the script path as the argument. 

Most of the script works... running into some bugs though. 

I'll keep y'all posted!

Michael 

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Maybe I should be more accurate, It's not "hidden", it's just not the default python environment.

You can find it here, depending on your ArcGIS Server installation

C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3

 

MichaelBouvet
Regular Contributor

Thanks so much! I will for sure try it and let you know!

0 Kudos
MichaelBouvet
Regular Contributor

I get this  (see attached screenshot) when I try to access the python.exe in that folder... I can follow the steps on the link they have there, but I am just worried it might mess something up since this is the production server... is that fear unfounded?

 

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

If you don't change the python environment, it should be fine.

But the safest way is to publish a web tool via ArcGIS Pro, it will use the Python3 environment on the server.

0 Kudos