Pro Version 3.1.1
ArcGIS Server 11.1
Using propy.bat the following code runs on my desktop without a hitch. When trying to run on Server it errors out with attached error.
For the life of me I can't figure why. Any insights would be appreciated!
# Imports
import os
import arcpy
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.features import FeatureLayerCollection
from datetime import datetime
# Define paths and files
unc_path = r'\\abc.local\AdminData\GIS'
root_path = os.path.join(unc_path, 'gis')
data_path = os.path.join(root_path, 'Database')
#project_path = os.path.join(root_path, "Projects", "Overnight", "overnight.aprx")
project_path = os.path.join(root_path, "Projects", "Overnight", "overnightDEV.aprx")
sdfile_path = os.path.join(root_path, "sdFiles")
db99_sde = os.path.join(data_path,"db99.sde")
gis_test = os.path.join(data_path,"gisTest.gdb")
workspace = os.path.join(data_path, 'Workspace.gdb')
behaviorNoOSS = os.path.join(campus_sde, "dbo.NoOss")
behaviorNoInc = os.path.join(campus_sde, "dbo.NoInc")
# other setup
arcpy.env.overwriteOutput = True
gis = GIS("https://servername.abc.local/portal", username="admin", password="adminPassword")
wksp = arcpy.EnvManager(scratchWorkspace=workspace, workspace=workspace)
shrOrg = True
shrEveryone = False
shrGroups = ""
# Process: Make Query Layer (Make Query Layer) (management)
student_temp = arcpy.management.MakeQueryLayer(input_database=db99_sde, out_layer_name="out_layer", query="select * from table", oid_fields=["id_number"])
I would try to dump out the value of 'db99_sde' to see what it is really set to. Are you publishing this code as a geoprocessing tool, or just copying it to the server? If you are doing a publish then that process (consolidation) can can alter source code statements that contain file paths (eg. unc_path = r'\\abc.local\AdminData\GIS')
Hi Chris. I would add "print" message after every relevant line to make sure your assignments are resulting in the strings that you expect. I've never used propy.bat but I assume it is something you run from the DOS command line, so those print statement should show up in the DOS window. If the path looks correct then you coud try to do a DOS "dir <path>" so see if the server can access it.
db99_sde = os.path.join(data_path,"db99.sde")
print ("db99_sde: " + db99_sde)
You will likely get more responses if you take the time to type out the errors and traceback instead of using a screenshot.
Is the server separate from your desktop? If so, do yo have Pro (and thus python 3.x) installed on the server computer as well?
R_