Select to view content in your preferred language

SyntaxError: EOL while scanning string literal

02-07-2022 01:16 AM
New Contributor

Hi guys, 

I am new to python , I am trying to read some data from CAD file using the below script , the script is works fine on Arcgis Pro 2.9.1 with no Errors But after publishing this to Arcgis server(10.9.1) as Geo-processing service and Submitting a job (post)  the job fails and showing me the following : 

  • esriJobMessageTypeError: File "<string>", line 31 arcpy.MakeFeatureLayer_management(CADSrs, CADlyr,g_ESRI_variable_3'") ^ SyntaxError: EOL while scanning string literal
  • esriJobMessageTypeError: Failed to execute (ImportCad).




my script :

# Import system modules
import arcpy
arcpy.env.workspace = arcpy.GetParameterAsText(0)
Request_ID = arcpy.GetParameterAsText(1)
# Step through each dataset in the list
for fd in arcpy.ListDatasets("*"):
    layers = ["Polyline", "Polygon", "Point"]
    for lyrGeom in layers:
        CADlyr = fd + "_" + lyrGeom
        CADSrs = fd + "/" + lyrGeom
        # Select the features on the drawing layer karar
        arcpy.MakeFeatureLayer_management(CADSrs, CADlyr, "\"Layer\" = 'karar'")
        with arcpy.da.SearchCursor(CADlyr,
                                   ["SHAPE@", "SHAPE@WKT", "OID@", "SHAPE@AREA", "SHAPE@LENGTH", "SHAPE@XY",
                                    "Layer"]) as cursor:
            for row in cursor:
                print("Feature {}:".format(row[2]))
                arcpy.AddMessage("Feature {}:".format(row[2]))
                print("Value of Spatial Reference = {}".format(row[0]
                sr = arcpy.SpatialReference(32637)
                newG = row[0].projectAs(sr)
                print (

the problem at the "\"Layer\" = 'karar'"   filter not accepted on runtime .

Reference of my code 

any idea how to solve this ,


thanks for advance for your help,

Tags (1)
0 Kudos
4 Replies
MVP Esteemed Contributor

Code formatting ... the Community Version - Esri Community

for line numbers etc

It sounds like you need to raw encode that line eg r"\some\path\some\file"

to ensure that the path is compliant with required specs.

Also don't mix "\" and "/" in paths as well

... sort of retired...
New Contributor

Thanks  DanPatterson for your reply, I've tried to add r but also didn't work for me.

0 Kudos
MVP Esteemed Contributor
New Contributor

An EOL ( End of Line ) error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error .

The SyntaxError: EOL while scanning string literal error in python occurs when while scanning a string of a program the python hit the end of the line due to the following reasons:

  • Missing quotes
  • Strings spanning multiple lines


0 Kudos