<?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: Phyton script fails to work through Windows 7 Task Scheduler in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679675#M52689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charles:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can open up Notepad and copy my example into the file and name it whatever you want.&amp;nbsp; I would place it in the same folder as the python script and a log file you can create that would provide information on how the bat process and python script functioned if you have arcpy.print messages written into it.&amp;nbsp; You would create a new Environmental Variable named PYTHONPATH that would be directed to the directory where python.exe is installed (In my case it is located at c:\Python26\ArcGIS10.0).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 May 2012 18:32:03 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2012-05-14T18:32:03Z</dc:date>
    <item>
      <title>Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679670#M52684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having difficulty making a Phyton script work through Windows 7 Task Scheduler. I created a Model and exported the Model to Python and then tried to schedule the script to run on Windows scheduler but I keep getting errors. The Model runs fine but the script fails each time. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Exported script is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Centerline_Update_COMMON_SDE.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Created on: 2012-05-10 16:34:42.00000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Description: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import arcpy module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Centerline_Update_New_shp = "C:\\DRIVE_D_LAST_COMPUTER_DIT51_MJ\\E_911_Data_06_2010\\E_911_Centerline_Update_2012\\Centerline_Update_New.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COMMON_SDE_CENTERLINE_METADATA_xml = "C:\\DRIVE_D_LAST_COMPUTER_DIT51_MJ\\E_911_Data_06_2010\\E_911_Centerline_Update_2012\\COMMON_SDE_CENTERLINE_METADATA.xml"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;devGIScommon_CREATOR_COMMON_trn_Centerline = "Database Connections\\TEST_Database Connection to vgissdedev.sde\\devGIScommon.CREATOR_COMMON.Transportation\\devGIScommon.CREATOR_COMMON.trn_Centerline"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Copy Features&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(Centerline_Update_New_shp, devGIScommon_CREATOR_COMMON_trn_Centerline, "", "0", "0", "0")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Metadata Importer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MetadataImporter_conversion(COMMON_SDE_CENTERLINE_METADATA_xml, devGIScommon_CREATOR_COMMON_trn_Centerline)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be greatly appreciated. Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Charles&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 13:16:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679670#M52684</guid>
      <dc:creator>CharlesBanks1</dc:creator>
      <dc:date>2012-05-14T13:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679671#M52685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charles:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How are you executing this python script in the Windows 7 Task Scheduler?&amp;nbsp; Are you calling the python script directly or are you calling it in another script such as a bat file?&amp;nbsp; I was having a similar issue on a Windows 2008 Server.&amp;nbsp; I had to add PYTHONPATH environmental variable to the directory where the python.exe file resides, in order for python to execute properly without having to specify the full path to the python scripts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition, under Task Scheduler I have set the task to run under highest privileges as this is what many other needed to configure in order for their scripts to run properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this information helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679671#M52685</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-14T15:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679672#M52686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am executing the .py file directly from the C: folder. The scheduler calls the .py file directly from my hard drive. Are there other tings taht I should be doing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 17:00:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679672#M52686</guid>
      <dc:creator>CharlesBanks1</dc:creator>
      <dc:date>2012-05-14T17:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679673#M52687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charles:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I execute all my python scripts from a bat file that I assign to the Scheduled Tasker.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a simple example of a bat file that calls 1 python script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@echo off&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;echo Start time: %time% &amp;gt; Road_Simplify.log&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;REM Run the python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;echo ------&amp;nbsp; Update time: %time%&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;echo ------&amp;nbsp; Removing Bezier curves from Roads&amp;nbsp; --------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;echo ------&amp;nbsp; Removing Bezier curves from Roads&amp;nbsp; -------- &amp;gt;&amp;gt; Road_Simplify.log&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;01_Bezier_Remover.py &amp;gt;&amp;gt; Road_Simplify.log&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;echo End time: %time% &amp;gt;&amp;gt; Road_Simplify.log&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@echo on&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please notice that I do not need the full path to the python script as I have PYTHONPATH set as an environmental variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 17:40:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679673#M52687</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-14T17:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679674#M52688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks again, but I am a bit confused. Are you setting this from Notepad? With where you have : 01_Bezier_Remover.py, being what my Python script should be? Where do you set "PYTHONPATH set as an environmental variable"?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 18:16:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679674#M52688</guid>
      <dc:creator>CharlesBanks1</dc:creator>
      <dc:date>2012-05-14T18:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679675#M52689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charles:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can open up Notepad and copy my example into the file and name it whatever you want.&amp;nbsp; I would place it in the same folder as the python script and a log file you can create that would provide information on how the bat process and python script functioned if you have arcpy.print messages written into it.&amp;nbsp; You would create a new Environmental Variable named PYTHONPATH that would be directed to the directory where python.exe is installed (In my case it is located at c:\Python26\ArcGIS10.0).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 18:32:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679675#M52689</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-14T18:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679676#M52690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry to be a bother. But how do I create a new env variable where phyton.exe is located?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 18:44:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679676#M52690</guid>
      <dc:creator>CharlesBanks1</dc:creator>
      <dc:date>2012-05-14T18:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679677#M52691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To create an Environmental Variable on Windows 2008 Server (It may be different on Windows 7 especially since it does not sound like it is a Server), you go to the Start menu in the lower left corner.&amp;nbsp; Right click on Computer in the right side pane and select Properties.&amp;nbsp; On the left side select Advanced system settings and near the bottom of this page is Environmental Variables.&amp;nbsp; Click on this button.&amp;nbsp; Click on New and set the variable as PYTHONPATH and browse to the directory where the Python.exe file is located.&amp;nbsp; That should do it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 19:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679677#M52691</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-14T19:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Phyton script fails to work through Windows 7 Task Scheduler</title>
      <link>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679678#M52692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 19:13:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/phyton-script-fails-to-work-through-windows-7-task/m-p/679678#M52692</guid>
      <dc:creator>CharlesBanks1</dc:creator>
      <dc:date>2012-05-14T19:13:22Z</dc:date>
    </item>
  </channel>
</rss>

