ArcPy is Broken in ArcGIS Pro

2319
5
08-17-2018 01:23 PM
GIS_Spellblade
Occasional Contributor

I'm on a split machine with limited rights, since I got upgraded to 2.2 my ArcPy is broken. I found the following two technical articles and am working with our IT to implement them. While I'm waiting, I wanted to know; is this issue related to that? Do I need to downgrade?

We've repaired, uninstalled and re-installed on admin-level logins. ArcGIS Pro works on the admin-level logins; does not work on the limited-rights login. ArcGIS Pro was subsequently uninstalled and re-installed on the limited-rights login using admin-level credentials. We have also tried resettting the application profile.

Problem: After upgrading to ArcGIS Pro 2.2, geoprocessing tools fail to load and Python window retur... 

Problem: Unable to create environments or install packages after upgrading to ArcGIS Pro 2.2 

ArcGIS Pro 2.1 (Geoprocessing Broken) 

This is the error message from ArcPy, and I have this one too:

User-added image

import arcpy

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\__init__.py", line 77, in <module>

    from arcpy.toolbox import *

  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\toolbox.py", line 716, in <module>

    from .na import AddFieldToAnalysisLayer as AddFieldToAnalysisLayer_na

  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\na.py", line 40, in <module>

    from arcpy import _na

  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_na\__init__.py", line 18, in <module>

    from ._sas import *

  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_na\_sas.py", line 59, in <module>

    class ServiceArea(cna.ServiceArea):

AttributeError: module 'arcpy._na' has no attribute 'ServiceArea'

0 Kudos
5 Replies
JoeBorgione
MVP Emeritus

Welcome aboard the ArcGIS 2.2 upgrade train:  I liken it to the Beatles 'Magical Mystery Tour' album.

Start here:  ArcGIS Pro 2.2.0 and Python Package Manager 

Move on to here:  https://community.esri.com/thread/217278-cannot-create-new-python-environment-in-arcgis-pro-22 

and if you still need more, search on 'Dan Patterson Blog'

That should just about do it....
GIS_Spellblade
Occasional Contributor

I found a fix from a comment in this thread; referencing a bad file path (in red): 

https://community.esri.com/thread/217056-error-with-toolboxes-in-arcgis-pro-22 

Hi Ghislain,

Thanks for the correction, you've put me on track to a solution! Upon "import arcpy", it seems that it's referencing a stray python path with a problematic version of numpy:

>>> import arcpy
Traceback (most recent call last):
  File "C:\Users\malcolm\AppData\Roaming\Python\Python36\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: cannot import name 'multiarray'

(and more stuff)

 

I list the paths:

 

>>> import sys
>>> for p in sys.path:
...     print(p)
...

 

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python36.zip
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DLLs
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
C:\Users\malcolm\AppData\Roaming\Python\Python36\site-packages
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages
C:\Program Files\ArcGIS\Pro\bin
C:\Program Files\ArcGIS\Pro\Resources\ArcPy
C:\Program Files\ArcGIS\Pro\Resources\ArcToolbox\Scripts
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\future-0.16.0-py3.6.egg
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\pytz-2018.3-py3.6.egg
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\sympy-1.1.1-py3.6.egg

 

(Highlighted bad path in red)

 

So, I can fix the problem just by renaming or removing the rogue Python location. But I am curious how the ArcGIS Pro Python installation found that path in the first place. Is C:\Users\%USERNAME%\AppData\Roaming\Python a standard path that a new Python installation looks for, or was this stored somewhere?

 

Again, my ArcGIS Pro problem is cured once I've removed the problematic files - just curious how the ArcGIS Pro Python installation got crosswise with it. Thanks very much for your help!

DanPatterson_Retired
MVP Emeritus

If you installed for all users, it puts the installation in the c:\program.... folder and dumps a path like that for individuals.

I install mine for me only in a different folder and the 'Users path doesn't exist since it isn't needed

GIS_Spellblade
Occasional Contributor

Thanks for the reply! I ran into a similar issue last year when I broke the Pro environment; afterwards, I think I used your technique of copying the folder as a cloned env in my main anaconda distribution to prevent it from happening again. I thought this was the same thing and have been battling this for more than a week.

This all affected my work computer so the response has been slow, and a lot harder without admin rights and with the installation in a central location.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Downgrade

0 Kudos