How can I use a Python 3 runtime environment with ArcGIS Server services?

2501
5
09-03-2018 04:32 PM
FrancescoTonini2
Occasional Contributor II

Everyone,

I am aware that ESRI provides instructions on how to install a python 3 runtime environment for a Linux ArcGIS Server installation. However, there is not a clear explanation on whether the aforementioned solution will apply to web services (e.g. geoprocessing services) published on ArcGIS Server for Linux or not. For example, if I publish a geoprocessing service that uses a number of libraries that only work with Python 3.5.x and later, how can I set up ArcGIS Server to use the python 3 runtime environment (installed with conda) as opposed to the default 2.7.x environment? Any help will be much appreciated.

5 Replies
deleted-user-QMDFe6f4fVmk
New Contributor

Bump x2

0 Kudos
EarlMedina1
Occasional Contributor III

It's been a while, but those chancing upon this page with Windows environments can see this page: Deploying custom Python packages for ArcGIS Server—Documentation | ArcGIS Enterprise 

  • Ignore the vague title - the contents of the page go over how to clone the default Python 3 environment, install new packages. It is also possible to activate the ArcGIS Server Python 3 environment to run Python 3 scripts, providing another option beyond ArcGIS Pro.

To answer your question Francesco, on Linux I believe to use Python 3 you simply have to be publishing from Pro. A windows Python 3 comes with the installation, located at: server/framework/runtime/ArcGIS/bin/Python/Scripts. Someone can correct me if I'm wrong, but out-of-the-box I think it uses with installation (via wine). To perform scripted operation, that's when you install the Linux-specific Python 3 installation. I'm not certain on a workflow to modify the default Python 3 environment accessed via wine...but perhaps the Windows documentation, if we suppose Wine is being used, might come into play to make changes/updates.

-Earl

CharlesFritz2
New Contributor III

So this seems straightforward to implement but it doesn't seem to be working for me on Windows Server 2016 running Enterprise 10.7.1.  Two things in the steps listed here: Deploying custom Python packages for ArcGIS Server—Documentation | Documentation for ArcGIS Enterpri...  seem vague - registry key editing, step 5 a and b. 

5.a If there is a PythonCondaEnv key in the Computer\HKEY_USERS\SID for ArcGIS Server Account\Software\ESRI\Server10.7 registry, delete that key. To determine the Security Identifier (SID) of the ArcGIS Server account, go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist or Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.

I am not sure if I am supposed to delete the key IF there is not PythonCondaEnv key. Or once I find the SID for the Arcgis Server Account what am I actually supposed to delete? These are regkeys not some creds in a text file. 

5.b In the Computer\HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\Server10.7 registry, update the value of the PythonCondaEnv key to the newenvname you just specified.

This one is way more straightforward than the former, but I am still not sure if I am supposed to supply it with the value of only the the environment, or the environment with the directory path. C:\program files\Arcgis...... I have tried both ways and neither are changing the outcome of publishing a tool so I think it has something to do with not deleting the Server Account SID.

Here is the error I receive when I attempt to publish a geoprocessing service, which makes sense:

ERROR 000574: Python is not installed.

Thank you in advance

0 Kudos
GiacomoFavaron
New Contributor III

have you found a solution? I am in a similar situation. It recognises the default conda environment but not the new one

0 Kudos
SusanHmel__DOIT_
New Contributor

This is an old thread but we ran into the same issue. We were attempting to change the default Python environment on a 10.7.1 server and while it seemed like it had taken, we would get the "ERROR 000574: Python is not installed. " when trying to publish a GP service. The service still appeared publish and would actually run, but would not do any Python imports or functions when running.

We started with our "cloned" new environment was copied in from another server  and put in the environments directory :

<install>\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\newenvname

We set the registry key to the newenvname and ran the proswap newenvname, restarted ArcGIS Server services and got the publishing error and the GP service that did show up in REST service didn't work.

We found that there is an important step in the details here deploying-custom-python-packages 10.9 that is not in deploying-custom-python-packages 10.7   - but it made a difference for us.

SusanHmel__DOIT__0-1654711064658.png

 

What we found was that the environment was cloned from another version (it was actually a Pro environment) and we needed to clone the default ArcGIS server environment on the server and then add the custom modules we needed.

But this time, we did everything logged into the server as the ArcGIS service account - the domain-level account that we have the runs the ArcGIS server service.

We found that starting the Python 3 Command prompt from the server would show the initial environment for that profile - not the new custom one we had used proswap to activate under a different windows login that we were publishing from.

We used the correct clone of the initial environment, set the registry key to use that, then used the proswap function to change the environment. Restarted the ArcGIS server service, and the  Python 3 Command prompt showed the new environment, then publishing the GP service from our other profile worked, no Python errors.

Hoping this helps someone else that comes across this issue.