<?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: import arcpy is crashing python in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366112#M76927</link>
    <description>&lt;P&gt;I'm having this problem as well. Sometimes importing arcpy would exit the entire runtime (with an exit status indicating non-successful exit). No amount of try-except recovery works except to re-run it. So "&lt;SPAN&gt;you&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;can&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;try/except an import statement" didn't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Can you share start-to-finish your procedure with scripts and error messages?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The OP literally gave the script and command (&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat&lt;/FONT&gt;) above. He couldn't find any error messages or logs.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Incidentally, what you're describing sounds like a rather odd way to go about this in the first place, but I'm assuming it's a test/proof-of-concept for something else?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I don't understand what you mean here. Is running a standalone script using arcpy supposed to be "odd"? Is arcpy supposed to be only ran in ArcGIS Pro? The only odd thing I find is how importing arcpy is non-deterministic and would sometimes kill the Python runtime. FYI this also happens in the Python REPL, not just running a script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat
Python 3.9.16 [MSC v.1931 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import arcpy
(base) PS C:\Users\user&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes, after typing &lt;FONT face="courier new,courier"&gt;import arcpy&lt;/FONT&gt;, it just exits the REPL.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The following is what I've tried. I was able to find the offending file that was causing this, as well as a stack trace. I hope this will be useful for you.&lt;/P&gt;&lt;P&gt;This is the command I'm running in powershell (the&amp;nbsp;` is intentional to escape the space in powershell). Some runs exits the script with a failing error code, but the last one has no problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
(base) PS C:\Users\user&amp;gt; $?
False
(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
(base) PS C:\Users\user&amp;gt; $?
False
(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
imported
(base) PS C:\Users\user&amp;gt; $?
True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;test.py&lt;/FONT&gt; has the following code (the first line is commented out when I wanted to run it multiple times). I repeatedly stepped into the import statement using the debugger&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;breakpoint()
import arcpy
print('imported')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got to the file&lt;/P&gt;&lt;PRE&gt;c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py&lt;/PRE&gt;&lt;P&gt;At line 131, there is an import:&lt;/P&gt;&lt;PRE&gt;from ._arcgisscripting import *&lt;/PRE&gt;&lt;P&gt;The arcgisscripting folder has files &lt;FONT face="courier new,courier"&gt;__init__.py&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;__pycache__&lt;/FONT&gt;, and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;_arcgisscripting.pyd&lt;/FONT&gt;. so this must be importing from the &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; file. Unfortunately &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; is an opaque DLL so I can't investigate any further.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can get to this part this by running the test.py code above. When in the debugger, &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt; will be visible on the left. Type the commands on the right as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
&amp;gt; c:\users\user\test.py(2)&amp;lt;module&amp;gt;()
-&amp;gt; import arcpy
(Pdb) b c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py:
131
Breakpoint 1 at c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__in
it__.py:131
(Pdb) c
&amp;gt; c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py(131)&amp;lt;m
odule&amp;gt;()
-&amp;gt; from ._arcgisscripting import *
(Pdb)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;, we add a breakpoint directly to the file. In the second &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;, we continue execution of importing arcpy, until it hits the breakpoint. The third &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;is when it hit the breakpoint and stops. You can type &lt;FONT face="courier new,courier"&gt;s&lt;/FONT&gt; here to jump into the import, but it was fruitless for me, because it seems to be importing from the &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; file, which is an opaque DLL.&lt;/P&gt;&lt;P&gt;Continuing from the above Pdb session, I can obtain a stack trace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt; c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py(131)&amp;lt;m
odule&amp;gt;()
-&amp;gt; from ._arcgisscripting import *
(Pdb) import traceback
(Pdb) traceback.print_stack()
  File "C:\Users\user\test.py", line 2, in &amp;lt;module&amp;gt;
    import arcpy
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 77, in &amp;lt;module&amp;gt;
    from arcpy.geoprocessing import gp
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in &amp;lt;module&amp;gt;
    from ._base import *
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in &amp;lt;module&amp;gt;
    import arcgisscripting
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py"
, line 131, in &amp;lt;module&amp;gt;
    from ._arcgisscripting import *
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\bdb.py", line 112, in dispatch_line
    self.user_line(frame)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 262, in user_line
    self.interaction(frame, None)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 357, in interaction
    self._cmdloop()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 322, in _cmdloop
    self.cmdloop()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 422, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\cmd.py", line 216, in onecmd
    return self.default(line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 381, in default
    exec(code, globals, locals)
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
(Pdb)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 03:42:20 GMT</pubDate>
    <dc:creator>Yik-ChingTsui</dc:creator>
    <dc:date>2024-01-04T03:42:20Z</dc:date>
    <item>
      <title>import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1365281#M76833</link>
      <description>&lt;P&gt;I am trying to debug a very simple python script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
print('OK')&lt;/LI-CODE&gt;&lt;P&gt;I am using Visual Studio Code (Windows 10 x64) which has been executed from a BAT file which activates &lt;FONT face="courier new,courier"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat&lt;/FONT&gt; before hand to ensure that the python environment is setup for ArcGIS Pro usage.&lt;/P&gt;&lt;P&gt;When I try to debug the script sometimes the script prints OK and sometimes is just crashes python on the first line. A try/except doesn't work here since the first line is causing python to completely crash and it will never reach the except part. I can repeat running the script in debug mode and to me it seems very random if it completes or crashes.&lt;/P&gt;&lt;P&gt;So far I haven't found any log entries anywhere which describes what is happening. It could be that the import part is checking for a valid license (I am using concurrent licensing) and that something in that check is faulting but it is very difficult to tell since I get no clues at all from the crash.&lt;/P&gt;&lt;P&gt;Can anyone give me a hint to where I can find more details or what could be the reason for these crashes?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 09:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1365281#M76833</guid>
      <dc:creator>CasperBørgesen</dc:creator>
      <dc:date>2024-01-02T09:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1365383#M76842</link>
      <description>&lt;P&gt;For what it's worth, you &lt;EM&gt;can&lt;/EM&gt; try/except an import statement.&amp;nbsp; That would at least rule out the issue being something to do with importing the module, itself.&amp;nbsp; You'd be checking for an&amp;nbsp;&lt;A title="Python 3 Official Docs" href="https://docs.python.org/3/library/exceptions.html#ImportError" target="_self"&gt;ImportError&lt;/A&gt;&amp;nbsp;exception.&lt;/P&gt;&lt;P&gt;The fact that it sounds transient makes me wonder if there's some sort of race condition or permissions lock in your setup that's causing this.&amp;nbsp; Can you share start-to-finish your procedure with scripts and error messages?&lt;/P&gt;&lt;P&gt;Incidentally, what you're describing sounds like a rather odd way to go about this in the first place, but I'm assuming it's a test/proof-of-concept for something else?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 15:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1365383#M76842</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2024-01-02T15:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366112#M76927</link>
      <description>&lt;P&gt;I'm having this problem as well. Sometimes importing arcpy would exit the entire runtime (with an exit status indicating non-successful exit). No amount of try-except recovery works except to re-run it. So "&lt;SPAN&gt;you&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;can&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;try/except an import statement" didn't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Can you share start-to-finish your procedure with scripts and error messages?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The OP literally gave the script and command (&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat&lt;/FONT&gt;) above. He couldn't find any error messages or logs.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Incidentally, what you're describing sounds like a rather odd way to go about this in the first place, but I'm assuming it's a test/proof-of-concept for something else?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I don't understand what you mean here. Is running a standalone script using arcpy supposed to be "odd"? Is arcpy supposed to be only ran in ArcGIS Pro? The only odd thing I find is how importing arcpy is non-deterministic and would sometimes kill the Python runtime. FYI this also happens in the Python REPL, not just running a script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat
Python 3.9.16 [MSC v.1931 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import arcpy
(base) PS C:\Users\user&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes, after typing &lt;FONT face="courier new,courier"&gt;import arcpy&lt;/FONT&gt;, it just exits the REPL.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The following is what I've tried. I was able to find the offending file that was causing this, as well as a stack trace. I hope this will be useful for you.&lt;/P&gt;&lt;P&gt;This is the command I'm running in powershell (the&amp;nbsp;` is intentional to escape the space in powershell). Some runs exits the script with a failing error code, but the last one has no problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
(base) PS C:\Users\user&amp;gt; $?
False
(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
(base) PS C:\Users\user&amp;gt; $?
False
(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
imported
(base) PS C:\Users\user&amp;gt; $?
True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;test.py&lt;/FONT&gt; has the following code (the first line is commented out when I wanted to run it multiple times). I repeatedly stepped into the import statement using the debugger&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;breakpoint()
import arcpy
print('imported')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got to the file&lt;/P&gt;&lt;PRE&gt;c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py&lt;/PRE&gt;&lt;P&gt;At line 131, there is an import:&lt;/P&gt;&lt;PRE&gt;from ._arcgisscripting import *&lt;/PRE&gt;&lt;P&gt;The arcgisscripting folder has files &lt;FONT face="courier new,courier"&gt;__init__.py&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;__pycache__&lt;/FONT&gt;, and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;_arcgisscripting.pyd&lt;/FONT&gt;. so this must be importing from the &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; file. Unfortunately &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; is an opaque DLL so I can't investigate any further.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can get to this part this by running the test.py code above. When in the debugger, &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt; will be visible on the left. Type the commands on the right as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;(base) PS C:\Users\user&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat .\test.py
&amp;gt; c:\users\user\test.py(2)&amp;lt;module&amp;gt;()
-&amp;gt; import arcpy
(Pdb) b c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py:
131
Breakpoint 1 at c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__in
it__.py:131
(Pdb) c
&amp;gt; c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py(131)&amp;lt;m
odule&amp;gt;()
-&amp;gt; from ._arcgisscripting import *
(Pdb)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;, we add a breakpoint directly to the file. In the second &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;, we continue execution of importing arcpy, until it hits the breakpoint. The third &lt;FONT face="courier new,courier"&gt;(Pdb)&lt;/FONT&gt;is when it hit the breakpoint and stops. You can type &lt;FONT face="courier new,courier"&gt;s&lt;/FONT&gt; here to jump into the import, but it was fruitless for me, because it seems to be importing from the &lt;FONT face="courier new,courier"&gt;.pyd&lt;/FONT&gt; file, which is an opaque DLL.&lt;/P&gt;&lt;P&gt;Continuing from the above Pdb session, I can obtain a stack trace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt; c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py(131)&amp;lt;m
odule&amp;gt;()
-&amp;gt; from ._arcgisscripting import *
(Pdb) import traceback
(Pdb) traceback.print_stack()
  File "C:\Users\user\test.py", line 2, in &amp;lt;module&amp;gt;
    import arcpy
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 77, in &amp;lt;module&amp;gt;
    from arcpy.geoprocessing import gp
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in &amp;lt;module&amp;gt;
    from ._base import *
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in &amp;lt;module&amp;gt;
    import arcgisscripting
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py"
, line 131, in &amp;lt;module&amp;gt;
    from ._arcgisscripting import *
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\bdb.py", line 112, in dispatch_line
    self.user_line(frame)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 262, in user_line
    self.interaction(frame, None)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 357, in interaction
    self._cmdloop()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 322, in _cmdloop
    self.cmdloop()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 422, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\cmd.py", line 216, in onecmd
    return self.default(line)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\pdb.py", line 381, in default
    exec(code, globals, locals)
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
(Pdb)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 03:42:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366112#M76927</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-01-04T03:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366118#M76928</link>
      <description>&lt;P&gt;What version of ArcGIS Pro?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 02:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366118#M76928</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-01-04T02:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366127#M76930</link>
      <description>&lt;P&gt;Not OP but I have the same problem. ArcGIS Pro version is 3.1.1. As for Python:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt; C:\Program` Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat --version
Python 3.9.16&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 03:38:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366127#M76930</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-01-04T03:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366210#M76942</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/700932"&gt;@Yik-ChingTsui&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I think we are facing the same issue and I can see that you have investigated the problem a bit further than me. Now we just have to convince ESRI to pick up the issue.&lt;/P&gt;&lt;P&gt;I have made a bug report, but it was closed since they couldn't reproduce the error.&lt;/P&gt;&lt;P&gt;What kind of licensing are you using (checking for a valid license is the only reasonable communication I expect the import to perform)?&lt;/P&gt;&lt;P&gt;I also use ArcGIS Pro 3.1.1 but the issue has affected several previous versions, might be going back to 2.6 but I'm not sure.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 11:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366210#M76942</guid>
      <dc:creator>CasperBørgesen</dc:creator>
      <dc:date>2024-01-04T11:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366651#M76978</link>
      <description>&lt;P&gt;Hi there, I'm not sure what you mean by "kind of licensing". I think I have an Advanced license. I also have a bunch of Esri Extensions like 3D Analyst and Spatial Analyst. Is there something you're looking for specifically? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 01:38:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366651#M76978</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-01-05T01:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366729#M76983</link>
      <description>&lt;P&gt;I'm more thinking in the line of how can I help ESRI dig into this issue. Since the issue is somewhat random I would expect the issue to be related to something which can change between each time we execute the scripts. We cannot look into the source code of the ESRI binaries (at least I'm not capable of reverse engineering the code), but we can tell them a bit about how we have setup ArcGIS Pro. Checking for a valid license is still my best guess to what could cause the issue. I am using a concurrent license and in my organisation we have a license server. So my question to you is how is your ArcGIS Pro configured related to licensing?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 09:48:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1366729#M76983</guid>
      <dc:creator>CasperBørgesen</dc:creator>
      <dc:date>2024-01-05T09:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1367243#M77070</link>
      <description>&lt;P&gt;Licensing as the problem makes sense to me. I'm also using a Concurrent Use License. I'm not quite sure how my organisation set up licensing. All I did was to follow their instructions and installed ArcGIS Pro from the company's internal store. I'm more of a programmer myself. I think we have a license server as well but I'll have to confirm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script is actually supposed to run on a client's ArcGIS Pro, and their licensing situation might be different and they might not have such a problem. I'll have to test in their offices.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 07:00:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1367243#M77070</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-01-08T07:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1377852#M78303</link>
      <description>&lt;BLOCKQUOTE&gt;I am using Visual Studio Code (Windows 10 x64) which has been executed from a BAT file which activates &lt;FONT face="courier new,courier"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat&lt;/FONT&gt; before hand to ensure that the python environment is setup for ArcGIS Pro usage.&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/324121"&gt;@CasperBørgesen&lt;/a&gt;, could you elaborate on this bit, what is the contents of the .bat file you are using to launch VSC?&lt;/P&gt;&lt;P&gt;You can use the VSC user settings to specify the default interpreter and command prompt profile. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"terminal.external.windowsExec": "C:\\Users\\&amp;lt;&amp;lt;your user name&amp;gt;&amp;gt;\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.profiles.windows": {
    "Command Prompt": {
        "path": [
            "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [
            "/k", "C:/Program Files/ArcGIS/Pro/bin/Python/Scripts/proenv.bat"
        ],
        "icon": "terminal-cmd",
    },
    // "Git Bash": {
    //     "source": "Git Bash"
    // }
},
"python.defaultInterpreterPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\python.exe",&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you try this rather than using the batch script to specify the launch environment for VSC?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, have you submitted a crash dump report for this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 22:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1377852#M78303</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2024-02-02T22:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1378577#M78379</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/50334"&gt;@HannesZiegler&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Thanks for responding! I have tried your settings for VS Code and I haven't been able to reproduce the issue when using just the following setting (made at least 20 runs and normally the issue appears after just a few):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"terminal.integrated.defaultProfile.windows": "Command Prompt",&lt;/LI-CODE&gt;&lt;P&gt;Even when I still use my batch script to run VS Code, which looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;@ECHO OFF

REM Set cmdcmdline to nothing to prevent proenv.bat from halting at the command line.
SET CMDCMDLINE=""

CALL "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat"

START "" "C:\Users\MYUSER\AppData\Local\Programs\Microsoft VS Code\Code.exe"&lt;/LI-CODE&gt;&lt;P&gt;The reason for why I use a batch script is that I try to emulate our production where we call various arcpy scripts from outside ArcGIS Pro and the environment is setup the same way using proenv.bat. We can see that lots of the calls to the arcpy scripts just fails silently at the exact line where arcpy is imported. So my guess is that the issue with VS Code is related to what we see in production where VS Code is not used.&lt;/P&gt;&lt;P&gt;I haven't been able to find any crash dumps so far and I don't think its created.&lt;/P&gt;&lt;P&gt;I guess the default terminal in VS Code is powershell, so what is the difference between running import arcpy in powershell and command prompt? And why does the issue seem random when running in powershell?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 10:20:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1378577#M78379</guid>
      <dc:creator>CasperBørgesen</dc:creator>
      <dc:date>2024-02-06T10:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1378803#M78399</link>
      <description>&lt;P&gt;What release / patch of Pro are you using? I cannot repro the crash on my end. Are you able to reproduce it using the powershell alone?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 19:09:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1378803#M78399</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2024-02-06T19:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1380201#M78522</link>
      <description>&lt;P&gt;I am using ArcGIS Pro 3.1.1. I have tried the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Open a PowerShell terminal&lt;/LI&gt;&lt;LI&gt;Run "&lt;FONT face="courier new,courier"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat&lt;/FONT&gt;"&lt;/LI&gt;&lt;LI&gt;Run "python my_script.py"&lt;/LI&gt;&lt;LI&gt;Repeat step 3 until it doesn't import arcpy&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Following the above recipe my first step 3 failed, and after about 8-10 more times it failed again.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 08:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1380201#M78522</guid>
      <dc:creator>CasperBørgesen</dc:creator>
      <dc:date>2024-02-09T08:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1382575#M78805</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/324121"&gt;@CasperBørgesen&lt;/a&gt;, thank you for providing those additional details. I am still unable to reproduce the issue. If your organization has authorization, please reach out to&amp;nbsp;&lt;A href="https://support.esri.com/en/contact-tech-support" target="_blank"&gt;Technical Support&lt;/A&gt;. Support will help you establish a reproducible workflow that will then help us debug and address the issue.&lt;/P&gt;&lt;P&gt;Note: To contact Technical Support, you need to be an authorized&amp;nbsp;caller. See&amp;nbsp;&lt;A href="https://community.esri.com/t5/my-esri-blog/why-can-t-i-submit-cases-or-how-i-became-an/ba-p/888179" target="_blank"&gt;Why can't I submit cases? (Or, How I became an authorized caller and reported my issue)&lt;/A&gt;&amp;nbsp;for more information.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 22:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1382575#M78805</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2024-02-14T22:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: import arcpy is crashing python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1419599#M82850</link>
      <description>&lt;P&gt;Has anyone tried to see if anti-virus and/or anti-malware software is the issue based on this documentation?&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/faq-how-do-i-troubleshoot-arcgis-pro-performance-issues-000025378#:~:text=Add%20exclusions%20by%20process%20executable" target="_blank" rel="noopener"&gt;https://support.esri.com/en-us/knowledge-base/faq-how-do-i-troubleshoot-arcgis-pro-performance-issues-000025378#:~:text=Add%20exclusions%20by%20process%20executable&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Does anyone see any errors in Event Viewer?&lt;/P&gt;&lt;P&gt;Has anyone gotten a simple Pro based python script to work in previous versions (e.g. Pro 2.x)?&amp;nbsp; Just wondering if this functionality broke with Pro 3.x major release.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 19:08:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-arcpy-is-crashing-python/m-p/1419599#M82850</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2024-05-06T19:08:27Z</dc:date>
    </item>
  </channel>
</rss>

