I am new to arcpy and most of python too. My new org has arcpy scripts (written by ex-employee) that would convert TAB files to shp and also create buffer zones in an shp. It was working great until we upgraded ArcGIS Pro to 2.8.3. With basic skills in python, I'm expected to debug this script. This is the script we are using -
#Import libraries
import geopandas as gpd
#Set directory as the same path as where this file is saved/pasted
abspath=os.path.abspath
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
#Create a subfolder within the directory, folder called siteboundary
ProjectFolder=dname
#Locate the tab file and set as variable
#The script is locating a file that ends with "Site Boundary.TAB"
files=os.listdir(ProjectFolder)
Tabfile=[i for i in files if i.endswith('Site Boundary.TAB')]
def listToString(s):
# initialize an empty string
str1 = " "
# return string
return (str1.join(s))
TabfilePath=ProjectFolder+'\\'+listToString(Tabfile)
#This creates the site boundary shapefile
Tabdata=gpd.read_file(TabfilePath,driver="MapInfo File")
ShapefilePath=ProjectFolder+r"\siteboundary.shp"
Tabdata.to_file(ShapefilePath)
#This creates the site's multiring buffer
#set arcpy environment
arcpyenv=ProjectFolder
#Allow arcpy to overwrite
arcpy.env.workspace=arcpyenv
arcpy.env.overwrite=True
arcpy.env.overwriteOutput = True
#Set multi ring buffer parameters
distances=[200,500,1000,2000]
bufferunit="meters"
arcpy.analysis.MultipleRingBuffer('siteboundary.shp','sitebuffer.shp',distances,bufferunit,"distance","NONE")
#Print end message when done
arcpy.AddMessage("Conversion done,your file is located in"+arcpyenv)
print("Conversion done,your file is located in "+arcpyenv)'```
We get the same error in all the PCs and also or all the scripts (json to shp and buffer and just buffer creation scripts). We are using scripts to semi-automate processes as we have to do plenty in a day.
I tried solving this issue from other sources' solutions, but none of them are relatable. For more details, after updating the ArcGIS Pro I had to clone the environment to run the scripts, I assume something might have happened there, but when I checked the installed libraries it had both arcpy 2.8 and geopandas 0.8.1 that are essential to run these scripts.
Another thing is, the scripts run only in one system where the ArcGIS is not updated and in the master of the machine's profile and none other.
I found that there was a problem with installing geopandas within ArcGIS Pro Python package management and also through anaconda prompt. So, I found this workaround on esri https://support.esri.com/en/technical-article/000024177. where you install geopandas through Python command prompt with this command line conda install geopandas libtiff=4.0.10
.
But this way, the notebooks in ArcGIS Pro will not work.
So you have to execute this command on the same python command prompt
conda install -c anaconda jupyter_client=5.3.1
Running these two codes in cloned environment resolved all the issues.