<?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: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804900#M2233</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How long has this been going on?&amp;nbsp; How is Pro licensed on your machine?&amp;nbsp; Can you remove the try/except block and share the full error and traceback?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Feb 2020 18:56:24 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2020-02-25T18:56:24Z</dc:date>
    <item>
      <title>Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804899#M2232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My scripts fail about half the time with error code 246 on importing the&amp;nbsp;ArcGIS API for Python when executing the script from a batch file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My batch file:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;@echo off&lt;BR /&gt;"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "C:\Users\jhuillery\Desktop\import_arcgis.py"&lt;BR /&gt;if errorlevel 1 (echo Failure Reason Given is %errorlevel%)&lt;BR /&gt;pause&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My script (&lt;SPAN style="background-color: #f6f6f6;"&gt;import_arcgis.py)&lt;/SPAN&gt;:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;print('importing sys...')&lt;BR /&gt;import sys&lt;BR /&gt;print(sys.executable)&lt;BR /&gt;print('importing arcgis...')&lt;BR /&gt;try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; from arcgis.gis import GIS&lt;BR /&gt;except ImportError:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print(sys.exc_info())&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;CMD output:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;importing sys...&lt;BR /&gt;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe&lt;BR /&gt;importing arcgis...&lt;BR /&gt;Failure Reason Given is 246&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm using:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Pro 2.5.0&lt;/LI&gt;&lt;LI&gt;ArcGIS API for Python 1.7.0&lt;/LI&gt;&lt;LI&gt;Windows 10 Enterprise&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 18:35:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804899#M2232</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-25T18:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804900#M2233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How long has this been going on?&amp;nbsp; How is Pro licensed on your machine?&amp;nbsp; Can you remove the try/except block and share the full error and traceback?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 18:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804900#M2233</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-02-25T18:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804901#M2234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure how long it has been going on. I've mostly noticed it after I upgraded to Pro 2.5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Licensing info:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="483279" class="image-1 jive-image" height="445" src="https://community.esri.com/legacyfs/online/483279_pastedImage_1.png" width="371" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CMD output with try/except removed:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;importing sys...&lt;BR /&gt;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe&lt;BR /&gt;importing arcgis...&lt;BR /&gt;Failure Reason Given is 246&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not getting Python errors because it seems like Python is crashing on the import statement.&lt;/P&gt;&lt;P&gt;This only happens when I run it through a cmd prompt. It only happens about half the time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 19:09:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804901#M2234</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-25T19:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804902#M2235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the &lt;A class="link-titled" href="https://docs.microsoft.com/en-us/windows/win32/debug/system-error-code-lookup-tool" title="https://docs.microsoft.com/en-us/windows/win32/debug/system-error-code-lookup-tool"&gt;The Microsoft Error Lookup Tool - Win32 apps | Microsoft Docs&lt;/A&gt;, code 246 matches two different results depending on whether it is hex or dec.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# for decimal 246 / hex 0xf6&lt;BR /&gt;&amp;nbsp; PCI_VERIFIER_DETECTED_VIOLATION&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bugcodes.h&lt;BR /&gt;# for hex 0x246 / decimal 582&lt;BR /&gt;&amp;nbsp; ERROR_ILLEGAL_CHARACTER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; winerror.h&lt;BR /&gt;# An illegal character was encountered. For a multi-byte&lt;BR /&gt;# character set this includes a lead byte without a&lt;BR /&gt;# succeeding trail byte. For the Unicode character set this&lt;BR /&gt;# includes the characters 0xFFFF and 0xFFFE.&lt;BR /&gt;# as an HRESULT: Severity: SUCCESS (0), FACILITY_NULL (0x0), Code 0x246&lt;BR /&gt;# for hex 0x246 / decimal 582&lt;BR /&gt;&amp;nbsp; ERROR_ILLEGAL_CHARACTER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; winerror.h&lt;BR /&gt;# An illegal character was encountered. For a multi-byte&lt;BR /&gt;# character set this includes a lead byte without a&lt;BR /&gt;# succeeding trail byte. For the Unicode character set this&lt;BR /&gt;# includes the characters 0xFFFF and 0xFFFE.&lt;BR /&gt;# 3 matches found for "246"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you were having a PCI_VERIFIER_DETECTED_VIOLATION issue, I am guessing you would be seeing a whole lot more problems, maybe even a BSOD.&amp;nbsp; So, that leaves the illegal character and the likely culprit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What program did you create your Python script in?&amp;nbsp; Did you copy and paste the code from somewhere?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, it could just be something got corrupted with Python when you installed/upgraded to Pro 2.5.&amp;nbsp; You could always try uninstalling and reinstalling Pro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 19:58:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804902#M2235</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-02-25T19:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804903#M2236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used Spyder to write the code originally.&lt;/P&gt;&lt;P&gt;I rewrote the code in plain old notepad and I'm getting the same issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same issue is happening when I get my coworkers to run it on their machines so I don't think it's a corrupted install.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 20:06:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804903#M2236</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-25T20:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804904#M2237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran your code on my Pro 2.5 Beta (I haven't upgraded to Pro 2.5 final yet) without any issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 20:33:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804904#M2237</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-02-25T20:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804905#M2238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you running it? It only happens when I run it from the cmd line.&lt;/P&gt;&lt;P&gt;Also it doesn't happen every time. It is very random.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 20:53:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804905#M2238</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-25T20:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804906#M2239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I opened up a new command prompt, and then typed in the path to the batch file containing the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 21:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804906#M2239</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-02-25T21:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804907#M2240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;That would cause the issue (sometimes) on the machines I've tested on.&amp;nbsp;&amp;nbsp;How can I get this resolved so my processes that run on the Task Scheduler don't fail randomly?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 21:16:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804907#M2240</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-25T21:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804908#M2241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any intermittent problem is challenging to solve, not just those with ArcGIS API for Python.&amp;nbsp; At this point, I don't have a whole lot of suggestions.&amp;nbsp; Do you see anything in the Windows event logs at the same time you are seeing the code fail to run?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 21:53:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804908#M2241</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-02-25T21:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804909#M2242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When it fails, it gives me result code =&amp;nbsp;2147942646 in the event logs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:17:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804909#M2242</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-26T15:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804910#M2243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No clue what's going on here but my temporary hack solution was to modify my .bat files to keep repeating the commands that run my scripts until the exit code = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;:StartLoop&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "C:\Users\jhuillery\Desktop\import_arcgis.py"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;IF %ERRORLEVEL% NEQ 0 GOTO StartLoop&lt;BR style="background-color: #f6f6f6;" /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;pause&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 16:52:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/804910#M2243</guid>
      <dc:creator>JohnHuillery1</dc:creator>
      <dc:date>2020-02-26T16:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1074742#M6299</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;My batch file:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;@echo off&lt;BR /&gt;"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "C:\Users\jhuillery\Desktop\import_arcgis.py"&lt;BR /&gt;if errorlevel 1 (echo Failure Reason Given is %errorlevel%)&lt;BR /&gt;pause&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/323133"&gt;@JohnHuillery1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Have you tried&amp;nbsp;&lt;SPAN&gt;pythonw.exe?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/python-questions/last-run-result-message-0xf6-when-trying-to-run-a-python-script/m-p/306100" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/python-questions/last-run-result-message-0xf6-when-trying-to-run-a-python-script/m-p/306100&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 15:25:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1074742#M6299</guid>
      <dc:creator>DanMcCoy1</dc:creator>
      <dc:date>2021-07-01T15:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1095993#M6596</link>
      <description>&lt;P&gt;I know this post was a bit older, but we are trying to solve the same type of issue and I was trying to replicate your batch file code here.&amp;nbsp; Were you running this through Windows Task Scheduler?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 16:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1095993#M6596</guid>
      <dc:creator>JeffHaupt</dc:creator>
      <dc:date>2021-09-07T16:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096014#M6598</link>
      <description>&lt;P&gt;Here's a more complete DOS batch file that uses a loop to check return codes from the python.exe. It will repeat the loop until it gets a return code == 0 or until the maximum number of tries is reached. So far, I haven't seen it go over 7 tries. Note: This is only checking the problem where Windows Task Scheduler is not executing python.exe. It is not checking to see if there was an error within the python script.&lt;/P&gt;&lt;P&gt;--------------------------------&lt;/P&gt;&lt;P&gt;SET log_file=c:\temp\Log.txt&lt;/P&gt;&lt;P&gt;ECHO ######################################################################### &amp;gt;&amp;gt; %log_file%&lt;BR /&gt;ECHO Batch start %date% Time: %time% &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;SET /A _counter=1&lt;BR /&gt;SET /A _max_tries=21&lt;BR /&gt;SET /A _wait_seconds=2&lt;/P&gt;&lt;P&gt;:LOOP&lt;/P&gt;&lt;P&gt;IF %_counter%==%_max_tries% (&lt;BR /&gt;ECHO GOTO END - max tries of [%_max_tries%] reached. &amp;gt;&amp;gt; %log_file%&lt;BR /&gt;GOTO :END&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;ECHO Attempt: [%_counter%] &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;ECHO Error level before python: [%errorlevel%] &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;:: Use the python exe to run our batch script.&lt;BR /&gt;:: Use full path to both python exe and python script.&lt;BR /&gt;"c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe" c:\temp\process.py&lt;/P&gt;&lt;P&gt;ECHO Error level after python: [%errorlevel%] &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;:: Check the python return code. If success then exit Else pause and try again.&lt;BR /&gt;IF %errorlevel%==0 (&lt;BR /&gt;ECHO GOTO END - success &amp;gt;&amp;gt; %log_file%&lt;BR /&gt;GOTO :END&lt;BR /&gt;)&lt;BR /&gt;ELSE (&lt;BR /&gt;ECHO Wait for some time. &amp;gt;&amp;gt; %log_file%&lt;BR /&gt;TIMEOUT %_wait_seconds% &amp;gt; NUL&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;ECHO After pause %date% Time: %time% &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;:: Increment the counter.&lt;BR /&gt;SET /A _counter=%_counter%+1&lt;/P&gt;&lt;P&gt;GOTO :LOOP&lt;/P&gt;&lt;P&gt;:END&lt;BR /&gt;ECHO Batch end %date% Time: %time% &amp;gt;&amp;gt; %log_file%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 16:47:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096014#M6598</guid>
      <dc:creator>BillMacPherson</dc:creator>
      <dc:date>2021-09-07T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096150#M6600</link>
      <description>&lt;P&gt;Thanks so much for providing that!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 22:09:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096150#M6600</guid>
      <dc:creator>JeffHaupt</dc:creator>
      <dc:date>2021-09-07T22:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096332#M6607</link>
      <description>&lt;P&gt;Here is a similar solution using a PowerShell script loop.&lt;/P&gt;&lt;P&gt;-------------------&lt;/P&gt;&lt;P&gt;$py_path="c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe"&lt;BR /&gt;$py_script="c:\temp\ps_Process.py"&lt;BR /&gt;$log_file="c:\temp\ps_log.txt"&lt;BR /&gt;$RandID = Get-Random -Minimum 1000 -Maximum 9999&lt;/P&gt;&lt;P&gt;$EMAIL_TO = "xyz@name.com"&lt;BR /&gt;$EMAIL_SUBJECT = "PS Loop Test"&lt;BR /&gt;$EMAIL_FROM = "abc@name.com"&lt;BR /&gt;$EMAIL_SERVER = "server_ip"&lt;/P&gt;&lt;P&gt;# Logging function to write to a text file.&lt;BR /&gt;Function Log {&lt;BR /&gt;param(&lt;BR /&gt;[Parameter(Mandatory=$true)][String]$msg&lt;BR /&gt;)&lt;BR /&gt;$FormattedDate = Get-Date -Format "MM-dd-yyyy hh:mm:ss tt"&lt;BR /&gt;Add-Content $log_file "$("PS")-$($RandID) $(" ") $($FormattedDate) $(" ") $($msg)"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Log "##########################################################"&lt;BR /&gt;Log "Start PowerShell"&lt;/P&gt;&lt;P&gt;$SUCCESS=1 # init to failed.&lt;BR /&gt;$py_return=""&lt;/P&gt;&lt;P&gt;for ($i = 0; $i -lt 10; $i++){&lt;BR /&gt;&amp;amp; $py_path $py_script&lt;BR /&gt;if($LASTEXITCODE -eq 0){&lt;BR /&gt;# success&lt;BR /&gt;Log "$i python.exe attempt success."&lt;BR /&gt;$SUCCESS=0&lt;BR /&gt;break&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;Log "$i python.exe attempt failed (LASTEXITCODE = $LASTEXITCODE)"&lt;BR /&gt;}&lt;BR /&gt;Start-Sleep -Seconds 5.0&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Log "LASTEXITCODE= $LASTEXITCODE"&lt;BR /&gt;Log "ERROR= $ERROR"&lt;BR /&gt;Log "?= $?"&lt;/P&gt;&lt;P&gt;if ($SUCCESS -eq 0) {&lt;BR /&gt;Log "Python.exe ran successfully."&lt;BR /&gt;$py_return="SUCCESS"&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;Log "Python.exe failed."&lt;BR /&gt;$py_return="FAILED"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;$SUBJECT="$EMAIL_SUBJECT - $py_return"&lt;BR /&gt;Send-MailMessage -From $EMAIL_FROM -To $EMAIL_TO -Subject $SUBJECT -Body "($py_return) Result from python." -SmtpServer $EMAIL_SERVER&lt;/P&gt;&lt;P&gt;Log "End PowerShell"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 12:53:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1096332#M6607</guid>
      <dc:creator>BillMacPherson</dc:creator>
      <dc:date>2021-09-08T12:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1274653#M8575</link>
      <description>&lt;P&gt;We were also having these sporadic failed arcpy imports resulting in a 246 error code using a stock arcgispro-py3 environment. Though the pythonw.exe and import looping workarounds did work, we found a permanent solution in adding an exception policy for the environment's python.exe in our server's antivirus software. This resolved all problems with importing arcpy. This might also explain why pythonw.exe worked - since it doesn't spawn a shell, it didn't trigger the same behaviour with our antivirus.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 13:37:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1274653#M8575</guid>
      <dc:creator>JakeKnowlesDMM</dc:creator>
      <dc:date>2023-04-03T13:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error code 246 when attempting to import ArcGIS API for Python through CMD prompt</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1398724#M9792</link>
      <description>&lt;P&gt;Not sure when it happened, but upgrading to different versions of ArcGIS Pro 2.x caused python 3 scripts to fail in the task manager. I couldn't figure out why my Python 3 scripts weren't working anymore while my Python 2 scripts were working fine. The task manager was not helpful in providing clues so I resorted to running them manually.&lt;/P&gt;&lt;P&gt;When I found this post the other day, I was hoping this would be a fix. I tried scheduling a batch file in the past and that was working intermittently as well. But today I confirmed I had a python 3 script take 3 tries before it was successful by looking at the log.&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 20:37:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/error-code-246-when-attempting-to-import-arcgis/m-p/1398724#M9792</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2024-03-20T20:37:18Z</dc:date>
    </item>
  </channel>
</rss>

