<?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: File Path Variables not working in Newer Versions of Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259651#M66893</link>
    <description>&lt;P&gt;Beyond Python 2 to Python 3, ArcGIS Pro also involved going from 32-bit to 64-bit.&amp;nbsp; Are you sure you have the proper database drivers installed since you are trying to access an enterprise geodatabase?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Feb 2023 15:22:32 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2023-02-18T15:22:32Z</dc:date>
    <item>
      <title>File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259397#M66879</link>
      <description>&lt;P&gt;I have a script that uses the Project geoprocessing tool and my script is giving me the "Parameters are not valid" error.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;The weird thing is my script works fine in python 2.7 but not in the python environment created by ArcGIS Pro 3.0.3 (python 3.9.11).&amp;nbsp; I have tried os.path.exists and it comes back as True in both versions.&amp;nbsp; I have tried the tool in ArcGIS Pro using the same file paths, tool works, I then export the tool as python script, doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;workspaceforCodes = "W:\\GIS\\Tools\\WorkspacesForTools\\Sync.gdb"
PBCGIS_BaseConnection = "W:\\GIS\\WORKING FILES\\EM Working Files\\Databases\\Source.sde"
fcSource = PBCGIS_BaseConnection + "\\PARCELS"
projectedOutput = workspaceforCodes + "\\PARCELS_reprojected"
print("Cleaning up workspace.  Removing old Reprojected Parcels.")
if arcpy.Exists(projectedOutput):
    arcpy.Delete_management(projectedOutput)
try:
    print("Reprojecting PARCELS to be Florida State Plane.")   # arcpy.Project_management
    arcpy.management.Project(in_dataset=fcSource, out_dataset=projectedOutput,
                             out_coor_system="102658",
                             transform_method="NAD_1983_To_HARN_Florida",
                             in_coor_system="102258",
                             preserve_shape="NO_PRESERVE_SHAPE", max_deviation="", vertical="NO_VERTICAL")
    print("PAO.PARCELS dataset reprojected to 'NAD_1983_StatePlane_Florida_East_FIPS_0901_Feet'"
          " from 'NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901'")

except():
    print("Projecting PBC Parcels failed. Check the variables for the 'Project' geoprocessing tool")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 16:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259397#M66879</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-02-17T16:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259414#M66880</link>
      <description>&lt;P&gt;Did you migrate the python script from python 2.7 to 3.x by just making the appropriate code changes?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 17:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259414#M66880</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2023-02-17T17:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259450#M66881</link>
      <description>&lt;P&gt;Code appears sound, besides the spaces in the file paths making my eye twitch.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure why those paths are tripping up the tool. In additon to&amp;nbsp;os.path.exists, you could try&amp;nbsp;&lt;SPAN&gt;os.access(fcSource, os.R_OK):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os

# Check if the file is readable
if os.access(fcSource, os.R_OK):
    print(f"You have read permission on the file {fcSource}")
else:
    print(f"You do not have read permission on the file {fcSource}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you shouldn't &lt;EM&gt;need&lt;/EM&gt; to... but you could try using "pathlib".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pathlib import Path
import arcpy

workspaceforCodes = Path("W:/GIS/Tools/WorkspacesForTools/Sync.gdb")
PBCGIS_BaseConnection = Path("W:/GIS/WORKING FILES/EM Working Files/Databases/Source.sde")
fcSource = PBCGIS_BaseConnection / "PARCELS"
projectedOutput = workspaceforCodes / "PARCELS_reprojected"

print("Cleaning up workspace. Removing old Reprojected Parcels.")
if arcpy.Exists(str(projectedOutput)):
    arcpy.Delete_management(str(projectedOutput))
try:
    print("Reprojecting PARCELS to be Florida State Plane.")
    arcpy.management.Project(in_dataset=str(fcSource), out_dataset=str(projectedOutput), out_coor_system="102658", transform_method="NAD_1983_To_HARN_Florida", in_coor_system="102258", preserve_shape="NO_PRESERVE_SHAPE", max_deviation="", vertical="NO_VERTICAL")
    print("PAO.PARCELS dataset reprojected to 'NAD_1983_StatePlane_Florida_East_FIPS_0901_Feet' from 'NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901'")
except Exception as e:
    print(f"Projecting PBC Parcels failed. Check the variables for the 'Project' geoprocessing tool: {e}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 17:58:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259450#M66881</guid>
      <dc:creator>DannyMcVey</dc:creator>
      <dc:date>2023-02-17T17:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259457#M66882</link>
      <description>&lt;P&gt;I originally made this script for python 2.7 and updated&lt;SPAN&gt;&amp;nbsp;the syntax or tool name changes.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 18:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259457#M66882</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-02-17T18:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259460#M66883</link>
      <description>&lt;P&gt;I tried the first suggestion in the ArcGIS Pro python window and I got the message: "You do not have read permission on the file...".&amp;nbsp; I am not sure how this makes sense when I can run the script in python 2.7?&lt;/P&gt;&lt;P&gt;I also tried the code changes from your second suggestion and I get the same message in the Try Statement and I also get this:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Traceback (most recent call last):
  File "W:\GIS\WORKING FILES\EM Working Files\Python Projects\Testing Phase\Update_WUD_PARCELS_toPBC.py", line 135, in &amp;lt;module&amp;gt;
    Parcels(prodDB_LandBase, prodDB_BaseConnection, workspaceforCodes, PBCGIS_BaseConnection, pbcgis_PropInfo)
  File "W:\GIS\WORKING FILES\EM Working Files\Python Projects\Testing Phase\Update_WUD_PARCELS_toPBC.py", line 70, in Parcels
    arcpy.CopyFeatures_management(fcInput, fcInput_copy)
  File "C:\Program Files\ArcGISPro\Resources\ArcPy\arcpy\management.py", line 4323, in CopyFeatures
    raise e
  File "C:\Program Files\ArcGISPro\Resources\ArcPy\arcpy\management.py", line 4320, in CopyFeatures
    retval = convertArcObjectToPythonObject(gp.CopyFeatures_management(*gp_fixargs((in_features, out_feature_class, config_keyword, spatial_grid_1, spatial_grid_2, spatial_grid_3), True)))
  File "C:\Program Files\ArcGISPro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 17 Feb 2023 18:21:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259460#M66883</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-02-17T18:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259488#M66887</link>
      <description>&lt;P&gt;Seems there's an unexpected difference in the way that windows, python, or arcpy is handling file permissions on your system.&lt;/P&gt;&lt;P&gt;Could you try executing the script as administrator? If you're running it inside ArcGIS Pro, you could try launching Pro as admin.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 19:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259488#M66887</guid>
      <dc:creator>DannyMcVey</dc:creator>
      <dc:date>2023-02-17T19:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259548#M66888</link>
      <description>&lt;P&gt;I just tried it as Admin and its the same error message as above.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 20:49:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259548#M66888</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-02-17T20:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259575#M66889</link>
      <description>&lt;P&gt;Sorry about that. I recommend getting further help from your IT resources or Esri technical support.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 21:36:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259575#M66889</guid>
      <dc:creator>DannyMcVey</dc:creator>
      <dc:date>2023-02-17T21:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259647#M66892</link>
      <description>&lt;P&gt;What's the W drive?&amp;nbsp; Can you specify it as a UNC path?&amp;nbsp; Have previously had issues with drive mappings for scheduled tasks.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 13:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259647#M66892</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-02-18T13:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259651#M66893</link>
      <description>&lt;P&gt;Beyond Python 2 to Python 3, ArcGIS Pro also involved going from 32-bit to 64-bit.&amp;nbsp; Are you sure you have the proper database drivers installed since you are trying to access an enterprise geodatabase?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 15:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1259651#M66893</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2023-02-18T15:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Variables not working in Newer Versions of Python</title>
      <link>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1260258#M66913</link>
      <description>&lt;P&gt;I took a second look at my code and made a couple changes.&amp;nbsp; First one was replacing the PBC connection to a local copy which is obtained from their hosted FeatureServer and using the Copy Features geoprocessing tool.&amp;nbsp; I then went through all my folder paths and changed them to what you suggested (Path(W:\blah)).&lt;/P&gt;&lt;P&gt;I noticed my script would get stuck on a geoprocessing tool that involved that particular feature class, which was stored on an Oracle geodatabase.&amp;nbsp; Do newer versions of arcpy have issues with Oracle geodatabase connections?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 21:37:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-variables-not-working-in-newer-versions/m-p/1260258#M66913</guid>
      <dc:creator>EvanMyers1</dc:creator>
      <dc:date>2023-02-21T21:37:54Z</dc:date>
    </item>
  </channel>
</rss>

