geoprocessing tool fails at 10.8.1, object has no attribute 'scratchFolder'

4146
13
Jump to solution
04-19-2021 07:47 AM
MattiasEkström
Occasional Contributor III

I have a geoprocessing tool that at the end exports points to a DWG-file, it's based on my own python script. It worked with ArcGIS Server 10.6.1, but when trying it with ArcGIS Enterprise 10.8.1 it doesn't work. I can run the tool in ArcMap and publish it succesfully to my server, but when running my geoprocessing service it fails and give me the error:

Error executing tool. Hojddata_till_DWG Job ID: jfcd1dee1b2364e73a10d9d90f4e5ef9b : Traceback (most recent call last): File "E:\arcgisserver\directories\arcgissystem\arcgisinput\Verktyg\Hojddata2dwg2.GPServer\extracted\v101\my_toolboxes\Export_Hojddata_to_DWG.py", line 24, in <module> arcpy.env.workspace = arcpy.arcpy.env.packageWorkspace.scratchFolder AttributeError: 'unicode' object has no attribute 'scratchFolder' Failed to execute (Hojddata2dwg). Failed to execute (Hojddata_till_DWG).

So I guess it has something with the scratchfolder to do, any ideas how to solve this?

The part of my python script that makes the dwg-export looks like this:

filename = "Hojdpunkter.dwg"
arcpy.ExportCAD_conversion(GridpointsZ, "DWG_R2010", filename)
outputFile = os.path.join(arcpy.env.scratchFolder, filename)  
arcpy.SetParameterAsText(2, outputFile)

 Has anything changed  between 10.6.1. and 10.8.1 of ArcGIS Server when it comes to scratchFolders or geoprocessing outputs?

Or is it me that has forgot how to properly publish a geoprocessing tool? I have set the parameters and the third one to be 'output' and 'data file'.

0 Kudos
2 Solutions

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

arcpy.env.workspace = arcpy.arcpy.env.packageWorkspace.scratchFolder AttributeError: 'unicode' object has no attribute 'scratchFolder' 

The error message means that arcpy.arcpy.env.packageWorkspace returns a string since the property is read only.  And it also means that the string has no attribute called scratchFolder, which a different arcpy.env environment parameter

Package Workspace (Environment setting)—ArcMap | Documentation (arcgis.com)

this will get you in the general vicinity of all the various "folders" in the help table of contents.


... sort of retired...

View solution in original post

0 Kudos
MattiasEkström
Occasional Contributor III

I marked Dans answer as the solution because it helpt me fix the first issue, that teh first error message was about.

Then I got help from ESRI Sweden support to finally get my GP-task working, we tested lots of different variants on setting output variable in my python script until we figured out it should be

#filename = "Hojdpunkter.dwg"
outputFile = os.path.join(arcpy.env.scratchWorkspace, "Hojdpunkter.dwg")
arcpy.ExportCAD_conversion(GridpointsZ, "DWG_R2010", outputFile)
arcpy.SetParameterAsText(2, outputFile)

 

instead of my original code (that worked in our old 10.6, but not in our new 10.8.1)

filename = "Hojdpunkter.dwg"
arcpy.ExportCAD_conversion(GridpointsZ, "DWG_R2010", filename)
outputFile = os.path.join(arcpy.env.scratchFolder, filename)  
arcpy.SetParameterAsText(2, outputFile)

 

problably won't help you @Arne_Gelfert  with your problem, but maybe someone else that find this thread later on.

View solution in original post

0 Kudos
13 Replies
DavidPike
MVP Frequent Contributor

Have you set a scratchWorkspace? Where is the scratchFolder pointing at the moment (print)?

0 Kudos
MattiasEkström
Occasional Contributor III

No I havn't set a scratchWorkspace, I want to use a deafult scratchWorkspace since I don't know what it is supposed to be on the server when running the geoprocessing task. This worked on my old server. When running the tool on my server from ArcMap (or as a standa alone script) It works fine and the scratchFolder is (C:\Users\...\AppData\Local\Temp\scratch).

Any tip on how I should print out the scratchFolder when running the geoprocessing task on the server?

0 Kudos
DanPatterson
MVP Esteemed Contributor

arcpy.env.workspace = arcpy.arcpy.env.packageWorkspace.scratchFolder AttributeError: 'unicode' object has no attribute 'scratchFolder' 

The error message means that arcpy.arcpy.env.packageWorkspace returns a string since the property is read only.  And it also means that the string has no attribute called scratchFolder, which a different arcpy.env environment parameter

Package Workspace (Environment setting)—ArcMap | Documentation (arcgis.com)

this will get you in the general vicinity of all the various "folders" in the help table of contents.


... sort of retired...
0 Kudos
MattiasEkström
Occasional Contributor III

I had the line 

 

arcpy.env.workspace = arcpy.env.scratchFolder

 

in the beginning of my code, which caused the error. I don't have to set the workspace since every output is specified to in_memory except the last export to dwg which is supposed to write the file to a default scratchFolder. I removed that line of code and don't get any errors. How ever there is still something wrong with my output, there is no dwg-file created.

I looked at my old working geoprocessing task in the rest service director and can see that I have one required input parameter with DataType: GPString (called Extent because it takes a string with an extent).
And one output parameter with DataType: GPDatafile.

But in my new task on the new server I have the same input parameter but the output parameter also has DataType: GPString  and I guess that's the problem. I've med a few tries and sometimes I don't get an output parameter at all.

How should I configure my output parameter when I add the script in ArcMap? And when I publish the tool as a Geoprocessing service? I've attached a coulpe of screenshots of what I thought would be the correct cofiguration (there is no option to choose GPDataFile, only DataFile).

But with this configuration I don't get an output parameter at all in my task when looking at it in teh rest service directory.

 

Task: export_dwg
Display Name: export_dwg
Description: Exports elevationdata to DWG
Execution Type: esriExecutionTypeSynchronous
Parameters:
    Parameter: Extent
        Data Type: GPString
        Display Name Extent
        Description: Extent to export
        Direction: esriGPParameterDirectionInput
        Dependency:
        Default Value: 146541 6350597 146641 6350665
        Parameter Type: esriGPParameterTypeRequired
        Category:

Supported Operations:   Execute Task 

 

  

0 Kudos
MattiasEkström
Occasional Contributor III

Turned out I had med output parameter configured wrong, it should be File and not DataFile that I used.

Now my geoprocessing task kind of work. But it gives a path to disk instead of a valid URL, which makes it useless.

0 Kudos
MattiasEkström
Occasional Contributor III

I marked Dans answer as the solution because it helpt me fix the first issue, that teh first error message was about.

Then I got help from ESRI Sweden support to finally get my GP-task working, we tested lots of different variants on setting output variable in my python script until we figured out it should be

#filename = "Hojdpunkter.dwg"
outputFile = os.path.join(arcpy.env.scratchWorkspace, "Hojdpunkter.dwg")
arcpy.ExportCAD_conversion(GridpointsZ, "DWG_R2010", outputFile)
arcpy.SetParameterAsText(2, outputFile)

 

instead of my original code (that worked in our old 10.6, but not in our new 10.8.1)

filename = "Hojdpunkter.dwg"
arcpy.ExportCAD_conversion(GridpointsZ, "DWG_R2010", filename)
outputFile = os.path.join(arcpy.env.scratchFolder, filename)  
arcpy.SetParameterAsText(2, outputFile)

 

problably won't help you @Arne_Gelfert  with your problem, but maybe someone else that find this thread later on.

0 Kudos
Arne_Gelfert
Occasional Contributor III

@MattiasEkström @DanPatterson - Man, I was really hopeful when I read Matthias' line 


It worked with ArcGIS Server 10.6.1, but when trying it with ArcGIS Enterprise 10.8.1 it doesn't work.

Having the same issue with GP Process not working after upgrading to Server 10.8.1 and applying all patches. But it still fails. I've narrowed it down to the line:

layout.exportToPDF(...)


When we get there, GP service bombs without any Python error in

arcgisjobs/../...gpserver/...some jobid .../scratch/messages.xml


I'm not used to seeing that. Usually the errors here help you fix your logic. Instead of a Python error, I get a Windows error:

Faulting application name: ArcSOC.exe, version: 12.6.0.24234, time stamp: 0x5ee81bca
Faulting module name: MappingCore.dll, version: 12.6.0.24241, time stamp: 0x5f8883dd
Exception code: 0xc0000005
Fault offset: 0x000000000049cfa4


My first  guess was it'd be a Python 2.x/3.x thing. I know there are some new features in 10.8.1. But all my imports are working fine. I can create an APRX from JSON using arcpy.mp with no issues.

This was published first from Pro 2.6.3, then at the suggestion of ESRI, after upgrading, from Pro 2.7.3. Still the same error.

Dan, adding you in here because you've been a life savor before. Ever seen that kind of DLL thing before. Is it Python? Is it AGS? I've checked all my AGS account permissions. No scratch folder issues. Paths all my sense. Looks something like this:

E:\arcgisserver\directories\arcgisjobs\..\.._gpserver\jf86961dfcf734510b848834890dc0e55\scratch\mylousyfilethatwontprint.pdf


Any pointers or thoughts appreciated.

0 Kudos
DanPatterson
MVP Esteemed Contributor

ArcSoc.exe and MappingCore.dll certainly aren't windows things and sorry @Arne_Gelfert I am fortunate to only have to deal with local in my work 😉 

 


... sort of retired...
0 Kudos
Arne_Gelfert
Occasional Contributor III

Not sure what you mean by "not windows things"... but thanks for the reply. If you're retired, gee, you will be missed! Have a good weekend!

0 Kudos