<?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: Obscure ExportToJPEG problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148187#M11515</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder if it fails before it even gets to python since raw formatting is interpreted by python.&amp;nbsp; There is chatter about enclosing the full path to the script in double quotes and use the full path to the python executable when using scheduled paths and even shortcuts&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Apr 2018 22:47:42 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-04-25T22:47:42Z</dc:date>
    <item>
      <title>Obscure ExportToJPEG problem</title>
      <link>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148186#M11514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a strange one ... would love to hear some feedback. I managed to fix the problem but I don't understand why this was a problem in the first place. I believe this has to do with how I was passing a directory string into the tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a relatively simple arcpy&amp;nbsp;script that exports jpegs to a folder. The script runs on a Windows 2008 R2 server where we have both ArcGIS Server 10.3.1 installed along with ArcGIS 10.3.1 desktop. Since the latter was the last installed, the default Python IDLE is 32-bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the script is run interactively in IDLE, it runs just fine with no errors. However, when run via Windows Task Scheduler, it throws the error "PageLayoutObject: Error in executing ExportToJPEG". I am 100% positive that it is running from the same user account when we run it either interactively in IDLE&amp;nbsp;or via Task Scheduler, and that that user account has the correct privileges to the writeoff directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The offending code is this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.mapping.ExportToJPEG(mxd, r"R:\GIS\Maps\Map_" + str(pageName) + ".jpg", resolution = 250)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I make a relatively minor change, it works fine:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;writeoff_dir = "//somedirectory/GIS/Maps/"&lt;/P&gt;&lt;P&gt;arcpy.mapping.ExportToJPEG(mxd,&amp;nbsp;writeoff_dir + "Map_" + str(pageName) + ".jpg", resolution = 250)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, I must emphasize that both code snippets work fine when run interactively in IDLE; it's only when the first snipped is run in Task Scheduler that it throws an error. I tried pointing Task Scheduler to a batch file that referenced either the 32-bit and 64-bit IDLE versions installed on the machine, but it didn't make a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So two questions for the community:&lt;/P&gt;&lt;P&gt;1. Why doesn't the input appear to like the 'r' prefix for the path?&lt;/P&gt;&lt;P&gt;2. Why would these both run fine interactively in IDLE but the first code snippet bomb via Task Scheduler?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance. At a minimum, I hope my solution helps someone experiencing the same uninformative error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2018 21:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148186#M11514</guid>
      <dc:creator>Waan</dc:creator>
      <dc:date>2018-04-25T21:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Obscure ExportToJPEG problem</title>
      <link>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148187#M11515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder if it fails before it even gets to python since raw formatting is interpreted by python.&amp;nbsp; There is chatter about enclosing the full path to the script in double quotes and use the full path to the python executable when using scheduled paths and even shortcuts&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2018 22:47:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148187#M11515</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-04-25T22:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Obscure ExportToJPEG problem</title>
      <link>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148188#M11516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Warren:&lt;/P&gt;&lt;P&gt;I know this question is old, I'm tracking a similar error and found this post.&amp;nbsp; I think your issue was a little different but thought I'd add a note since I was here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If folder&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;R:\GIS\Maps is a network/mapped drive, then it won't be accessible to task the account (even if it's the same account) when running as a background task.&amp;nbsp; Mapped drives are pretty much a "GUI only" thing unless your bat file/script creates it explicitly with the OS command.&amp;nbsp; The task scheduler runs as your defined account but doesn't load all the GUI aspects.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;So when you changed the path to the UNC style "//machine/GIS/Maps", it works b/c that path is resolvable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;Hope that helps someone else, back to tracking down my issue...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2020 18:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/obscure-exporttojpeg-problem/m-p/148188#M11516</guid>
      <dc:creator>FredSpataro</dc:creator>
      <dc:date>2020-03-04T18:25:54Z</dc:date>
    </item>
  </channel>
</rss>

