Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • "import arcpy" crashing Stat (19.5 and 18.5)

    Dear Readers

    After a couple of years I tried to rerun some Stata programmes that include ArcGis Pro (now 3.7) commands. I used the same set up, but although I set the python exec appropriately Stata (19.5 up to date) crashes when I try to import arcpy
    Code:
    python query
    local initialised = "`r(initialized)'"
    di `r(initialized)'
    if "`r(initialized)'" ~= "1" {
        python set exec "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe"
        python set userpath "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\"
    }
    
    python
    import arcpy
    CRASH

    Any ideas? The likeliest explanation is that the ArcGis python version is incompatible with the arcpy version, but I don't know why they would be different.

    In a "cmd" window I can run the ArcGis python version and import arcpy, and it works.
    Click image for larger version

Name:	pythonArcpy.jpg
Views:	1
Size:	35.9 KB
ID:	1787092


    Thanks for your attention and best wishes.

    Richard

  • #2
    Dear Readers

    I'm still unable to load (Esri) ArcPy from Stata despite ongoing assistance from Stata Technical (much appreciated).

    It seems I can't load NumPy, which seems a more general problem - i.e. not specific to ArcPy. A second (laptop) Windows 11 Pc has the same problem

    Has anyone else experienced this? Was a solution found?

    Thanks for attention

    Richard

    Comment


    • #3
      I gave it a try.
      I'm using Stata 18 on Windows 11 and had no problems installing numpy with a simple "pip install numpy" from Windows Powershell. It was installed in the writable "Users" folder.

      Stata had no issue finding it either. This is the code I ran:
      Code:
      python set exec "c:\Program Files\Python312\python.exe", permanently
      
      python:
      import numpy
      print(numpy.__file__)
      end
      
      python:
      import numpy as np
      
      a = np.array([1, 2])
      b = np.array([3, 4])
      
      result = np.dot(a, b)
      
      print(result)
      end

      And this was the result:
      Code:
      . python set exec "c:\Program Files\Python312\python.exe", permanently
      (python_exec preference recorded)
      
      . 
      . python:
      ----------------------------------------------- python (type end to exit) ---------------------------------------------------------------------------------------
      >>> import numpy
      >>> print(numpy.__file__)
      C:\Users\evgeny\AppData\Roaming\Python\Python312\site-packages\numpy\__init__.py
      >>> end
      -----------------------------------------------------------------------------------------------------------------------------------------------------------------
      
      . 
      . python:
      ----------------------------------------------- python (type end to exit) ---------------------------------------------------------------------------------------
      >>> import numpy as np
      >>> 
      >>> a = np.array([1, 2])
      >>> b = np.array([3, 4])
      >>> 
      >>> result = np.dot(a, b)
      >>> 
      >>> print(result)
      11
      >>> end
      -----------------------------------------------------------------------------------------------------------------------------------------------------------------

      Comment

      Working...
      X