1

I have written a simple code in python for clipping. The code is :

    #Step 1 To clip the Study area
    import arcpy
    import os
    import sys
    from arcpy import env
    from arcpy.geoprocessing import gp
    #Set Workspace
    arcpy.env.workspace = r"C:\test"
    # set local variables
    in_features = arcpy.GetParameterAsText(0)
    clip_features = arcpy.GetParameterAsText(1)
    out_feature_class = arcpy.GetParameterAsText(2)
    xy_tolerance = ""
    # Execute Clip
    arcpy.Clip_analysis(in_features, clip_features, out_feature_class,  xy_tolerance)

On execution I am getting this error message:

 Executing: Script C:\test\lithology.shp C:\test\study.shp 0.0001 C:\test\lithoclip.shp
 Start Time: Wed May 30 18:41:05 2018
 Running script Script...

Traceback (most recent call last):
File "D:\kiran\test.py", line 9, in <module>
import arcpy
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\__init__.py", line 21, in <module>
from arcpy.geoprocessing import gp
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 578, in <module>
env = GPEnvironments(gp)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 575, in GPEnvironments
return GPEnvironment(geoprocessor)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 528, in __init__
import weakref
File "C:\Anaconda2\Lib\weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Failed to execute (Script).

Can anyone help me understand where I am making the mistake?

  • the first and the second parameter i suppose they are feature class. What about the third parameter? what type of parameter have you chosen? – Florjan May 30 '18 at 14:07
  • Try removing the following lines: from arcpy import env & from arcpy.geoprocessing import gp – Hornbydd May 30 '18 at 15:32
  • @Hornbydd ..still same error – Paria May 31 '18 at 7:34
  • Looking at your parameter order, very first line in error message suggests that parameter 3 is your tolerance but your output FC is the fourth. Also you supply a tolerance value then you use an empty string in the actual clip tool. – Hornbydd May 31 '18 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.