You have not specified what your hwsd_csv
value is. However, you need to use the name of the data source, not the name of the table view when removing a join.
So, based on the values in the error message, perhaps the following might work:
arcpy.RemoveJoin_management("hwsd_lyr", "HWSD_CLS_DATA")
or possibly:
arcpy.RemoveJoin_management("hwsd_lyr", "HWSD_CLS_DATA.csv")
The documentation at ArcGIS Pro / Tool Reference / Tools / Data Management toolbox / Joins and Relates toolset / Remove Join states:
The join name will not reflect the name of the table view itself, but rather the source of the table view. Therefore, if a table view is named TableView1
and points at mytable.dbf
, the name of the join will be "mytable"
.
Alternatively, you can just remove all joins by not specifying the join name at all:
arcpy.RemoveJoin_management("hwsd_lyr")