<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Arcpy scripts keep giving an error &amp;quot;TypeError: expected string or bytes-like object&amp;quot; in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106372#M46553</link>
    <description>&lt;P&gt;What version of Pro are you upgrading from?&lt;/P&gt;&lt;P&gt;I would start putting in print statements to ensure that variables are being populated as expected.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Oct 2021 12:18:27 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2021-10-11T12:18:27Z</dc:date>
    <item>
      <title>Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106353#M46551</link>
      <description>&lt;P&gt;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 -&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;#Import libraries&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; geopandas &lt;SPAN class=""&gt;as&lt;/SPAN&gt; gpd

&lt;SPAN class=""&gt;#Set directory as the same path as where this file is saved/pasted&lt;/SPAN&gt;
abspath=os.path.abspath
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

&lt;SPAN class=""&gt;#Create a subfolder within the directory, folder called siteboundary&lt;/SPAN&gt;
ProjectFolder=dname


&lt;SPAN class=""&gt;#Locate the tab file and set as variable&lt;/SPAN&gt;
&lt;SPAN class=""&gt;#The script is locating a file that ends with "Site Boundary.TAB"&lt;/SPAN&gt;
files=os.listdir(ProjectFolder)
Tabfile=[i &lt;SPAN class=""&gt;for&lt;/SPAN&gt; i &lt;SPAN class=""&gt;in&lt;/SPAN&gt; files &lt;SPAN class=""&gt;if&lt;/SPAN&gt; i.endswith(&lt;SPAN class=""&gt;'Site Boundary.TAB'&lt;/SPAN&gt;)]
&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;listToString&lt;/SPAN&gt;(&lt;SPAN class=""&gt;s&lt;/SPAN&gt;): 
    
    &lt;SPAN class=""&gt;# initialize an empty string&lt;/SPAN&gt;
    str1 = &lt;SPAN class=""&gt;" "&lt;/SPAN&gt; 
    
    &lt;SPAN class=""&gt;# return string  &lt;/SPAN&gt;
    &lt;SPAN class=""&gt;return&lt;/SPAN&gt; (str1.join(s))
TabfilePath=ProjectFolder+&lt;SPAN class=""&gt;'\\'&lt;/SPAN&gt;+listToString(Tabfile)



&lt;SPAN class=""&gt;#This creates the site boundary shapefile&lt;/SPAN&gt;
Tabdata=gpd.read_file(TabfilePath,driver=&lt;SPAN class=""&gt;"MapInfo File"&lt;/SPAN&gt;)
ShapefilePath=ProjectFolder+&lt;SPAN class=""&gt;r"\siteboundary.shp"&lt;/SPAN&gt;
Tabdata.to_file(ShapefilePath)


&lt;SPAN class=""&gt;#This creates the site's multiring buffer&lt;/SPAN&gt;

&lt;SPAN class=""&gt;#set arcpy environment&lt;/SPAN&gt;
arcpyenv=ProjectFolder

&lt;SPAN class=""&gt;#Allow arcpy to overwrite&lt;/SPAN&gt;
arcpy.env.workspace=arcpyenv
arcpy.env.overwrite=&lt;SPAN class=""&gt;True&lt;/SPAN&gt;
arcpy.env.overwriteOutput = &lt;SPAN class=""&gt;True&lt;/SPAN&gt;

&lt;SPAN class=""&gt;#Set multi ring buffer parameters &lt;/SPAN&gt;
distances=[&lt;SPAN class=""&gt;200&lt;/SPAN&gt;,&lt;SPAN class=""&gt;500&lt;/SPAN&gt;,&lt;SPAN class=""&gt;1000&lt;/SPAN&gt;,&lt;SPAN class=""&gt;2000&lt;/SPAN&gt;]
bufferunit=&lt;SPAN class=""&gt;"meters"&lt;/SPAN&gt;
arcpy.analysis.MultipleRingBuffer(&lt;SPAN class=""&gt;'siteboundary.shp'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'sitebuffer.shp'&lt;/SPAN&gt;,distances,bufferunit,&lt;SPAN class=""&gt;"distance"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;"NONE"&lt;/SPAN&gt;)


&lt;SPAN class=""&gt;#Print end message when done&lt;/SPAN&gt;
arcpy.AddMessage(&lt;SPAN class=""&gt;"Conversion done,your file is located in"&lt;/SPAN&gt;+arcpyenv)
&lt;SPAN class=""&gt;print&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"Conversion done,your file is located in "&lt;/SPAN&gt;+arcpyenv)&lt;SPAN class=""&gt;'```


 [Here'&lt;/SPAN&gt;s the image of the error][&lt;SPAN class=""&gt;1&lt;/SPAN&gt;] 



  [&lt;SPAN class=""&gt;1&lt;/SPAN&gt;]: https://i.stack.imgur.com/z89Vs.png

&lt;/PRE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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 would be very grateful if anyone could help me with this.&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 09:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106353#M46551</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2021-10-11T09:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106372#M46553</link>
      <description>&lt;P&gt;What version of Pro are you upgrading from?&lt;/P&gt;&lt;P&gt;I would start putting in print statements to ensure that variables are being populated as expected.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:18:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106372#M46553</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-10-11T12:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106375#M46554</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/527944"&gt;@Sahaja&lt;/a&gt;&amp;nbsp;have you updated from an old Pro version or from ArcMap?&lt;/P&gt;&lt;P&gt;Python 3.6 handles binary differently to 2.7, so maybe this is a 2.7 script that needs updating?&lt;/P&gt;&lt;P&gt;In fact, you have Print statements in there, which you don't do at 3.6 anymore, so definitely an ArcMap script.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106375#M46554</guid>
      <dc:creator>David_Brooks</dc:creator>
      <dc:date>2021-10-11T12:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106489#M46570</link>
      <description>&lt;P&gt;What are the errors you are getting?&amp;nbsp; Screen caps would be good...&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 17:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106489#M46570</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-10-11T17:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106566#M46579</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Error.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/24991iB0A06414DB2101FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Error.png" alt="Error.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;That's the error. I found that it's the problem in importing geopandas.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 00:23:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106566#M46579</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2021-10-12T00:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106567#M46580</link>
      <description>&lt;P&gt;Updated from 2.8.0 to 2.8.2 in one PC, in the other it was still in 2.8.0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I found that the error is given when importing geopandas. the installed geopandas is 0.8.1&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 00:25:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1106567#M46580</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2021-10-12T00:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1108725#M46879</link>
      <description>&lt;P&gt;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&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://support.esri.com/en/technical-article/000024177" target="_blank" rel="nofollow noopener noreferrer"&gt;https://support.esri.com/en/technical-article/000024177&lt;/A&gt;. where you install geopandas through Python command prompt with this command line&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;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&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;conda install -c anaconda jupyter_client=5.3.1&lt;/P&gt;&lt;P&gt;Running these two codes in cloned environment resolved all the issues.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 07:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1108725#M46879</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2021-10-19T07:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1108807#M46886</link>
      <description>&lt;P&gt;Good for you for sticking with it.&amp;nbsp; I have to ask, what is it that geopandas offers that is worth that much trouble?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:04:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1108807#M46886</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-10-19T14:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy scripts keep giving an error "TypeError: expected string or bytes-like object"</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1110029#M47020</link>
      <description>&lt;P&gt;An ex-employee wrote a few scripts that would convert site area in json or tab or any file to shp and also create a buffer of 200m,500m,1km,and 2km in one shp with one script. This makes our lives easy in reducing the robotic efforts every time we have to do a new report in the company.&lt;/P&gt;&lt;P&gt;Thank you for trying to figure out the issue with me&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 23:14:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-scripts-keep-giving-an-error-quot-typeerror/m-p/1110029#M47020</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2021-10-21T23:14:52Z</dc:date>
    </item>
  </channel>
</rss>

