ArcPy fails to import when not logged into host machine

5543
11
11-08-2018 08:23 AM
ShaneBuscher1
New Contributor III

I am trying to run a python script on a server that I am not logged into. The script runs fine when I log into the server and execute. However, when the python script is executed through an automated process (not logged in) I receive the following error: 

Traceback (most recent call last):
  File ".\Python\Scripts\DeployGeodatabase.py", line 1, in <module>
    import arcpy
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 72, in <module>
    from arcpy.geoprocessing import gp
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from ._base import *
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
RuntimeError: Not signed into Portal.

arcpy is unable to be imported because, for some unknown reason, it can't determine there is an available ArcGIS Pro license when not directly logged in. 

The automated process consists of an Octopus deployment task. Essentially Octopus has a Windows service run by the Local System account. When a deployment occurs the service invokes a local powershell script that kicks off the python script. I tried switching the account that runs the service to a local administrator to no avail. Not sure where to go from here since I can successfully run the powershell script when logged in. 

How do I get this to work? 

Tags (2)
0 Kudos
11 Replies
SteveLewis
Occasional Contributor

I need to run ArcPy 3.6 from SQL Server's EXEC xp_cmdshell   This always worked in Python 2.7.  It is an integrated process so won't work to run it from like Windows Scheduler.  

When I attempt to run ArcPy 36,  'C:\Python3x\arcgispro-py3-clone\Python.exe F:\TEST\TEST.py'  is says license is not initialized.  

I integrated this into the script and it connects to the license on my portal if run from CMD.  Also tried single use license from SQL Server or just "Pro"  

 

This connects to license server at cmd line. 

from arcgis.gis import GIS
gis=GIS(url="https://MyPortal/portal", username="MyUser", password="MyPass")

import arcpy

0 Kudos
SteveLewis
Occasional Contributor

Never could get 3.6 working from SQL Server xp_cmdshell  integrated process (licensing issue), back to using ArcPy 2.7 

0 Kudos