I am trying to remove a join in arcpy and have been all over the forums and help topics but cannot get my script to remove the join.

I have tried many combinations of inputs to the remove join but to no avail.

Name94 = "C:\\a\\b\\c\\input1.shp"
Name95 = "C:\\a\\b\\c\\input2.shp"
TablesView = "C:\\a\\b\\c\\TablesView.lyr"
arcpy.MakeFeatureLayer_management(Name94, TablesView)
arcpy.AddJoin_management(TablesView, "Buf_Units", Name95, "Units", "KEEP_ALL")
arcpy.CalculateField_management(TablesView, "Buf_Area", "[Area]", "VB", "") 
arcpy.RemoveJoin_management(TablesView, "Buf_Units")

This yields the error:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of  | Input2.
Failed to execute (RemoveJoin).

In place of buf_units I have tried:

arcpy.RemoveJoin_management(TablesView, "'"+Name95.rstrip(".shp")+"'")
arcpy.RemoveJoin_management(TablesView, "input2")
arcpy.RemoveJoin_management(TablesView, Name95)
arcpy.RemoveJoin_management(TablesView, "units")

The previous error is the result of most of these tries but when it is not it is:

ExecuteError: ERROR 000229: Cannot open C:\a\b\c\TablesView.lyr
Failed to execute (RemoveJoin).

I am running python 2.7, 64bit, 10.1 arcgis

  • Are you running this inside of ArcMap ? or running it from an IDE? Cannot open errors happened to me when I forgot to specify a working environment. – Martin Jan 27 '15 at 20:23
  • I am running in pythonwin. The code above is just a snipet. I have a working environment set. TablesView is implicitly defined as well (C:\\a\\b\\c\\TablesView.lyr) I had to implicitly create layer files for my make feature layer operations to work in a loop. – D_C Jan 27 '15 at 20:27
  • I think your question will be much easier to answer if you edit it to focus on why just one of your examples is not working. Taking your first example, what are the variable name94, name95 and TablesView set to when you run it? I recommend adding print statements to one of your code snippets to show us along with the precise error message that is thrown by that code snippet. – PolyGeo Jan 27 '15 at 21:48
  • From your very first example, simply try: Name95.rstrip(".shp") (without the addition of quotes). – KHibma Jan 27 '15 at 21:59
  • @KHibma tried it and got error 000800. Parameters are not valid. The value is not a member of | ISOstep95 – D_C Jan 27 '15 at 22:47

I think your code doesn't work because MakeFeatureLayer_management() creates a layer (in memory) , not a layer file (.lyr).

Just replace your TablesView variable, e.g.

TablesView = "TablesView"

and you shouldn't get that error anymore.

|improve this answer|||||
  • Of all the combinations I tried, I did not try that. That did it! Thanks. arcpy.RemoveJoin_management("TablesView") – D_C Jan 29 '15 at 16:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.