Select to view content in your preferred language

IDLE for ArcGIS Pro won't load ArcPy due to Environmental Variable Path -- How do I Fix??

546
3
09-13-2024 10:28 AM
DS_GIS
by
Occasional Contributor

Hello, 

I've been troubleshooting this for hours and have figured out the problem, but not the solution. So, I'm trying to load ArcPy using 'import arcpy' in IDLE 3.10.11 for ArcGIS Pro and receiving.

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import arcpy
ModuleNotFoundError: No module named 'arcpy'

I have an academic Advanced license for ArcGIS Pro. So, this is not an issue due to licensing. I figured out that the issue likely stems from my Environmental Variables and System pathing. I have secondary installs of Python that I work in using Anaconda & Jupyter notebooks outside of ArcGIS Pro. These were installed BEFORE ArcGIS Pro though. Yet, they seem to be stomping on the ArcGIS Pro system path. 

This was discovered by running the below code.

import sys

print(sys.path)

Which showed me that my IDLE is not pointed to my ArcGIS Pro folders remotely. 

Here is the result of my System Path:

['', 'C:\\WINDOWS\\system32', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64\\python310.zip', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64\\DLLs', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64\\lib', 'C:\\Users\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10', 'C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10\LocalCache\\local-packages\\Python310\\site-packages', 'C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10\LocalCache\\local-packages\\Python310\\site-packages\\win32', 'C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10\\LocalCache\\local-packages\\Python310\\site-packages\\win32\\lib', 'C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10\\LocalCache\\local-packages\\Python310\\site-packages\\Pythonwin', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64\\lib\\site-packages']

I've attempted the below to troubleshoot the issue:

  • Append new system path line items to the correct paths >> ArcPy still wouldn't load
  • Uninstall ArcGIS Desktop from my system >> I don't have a license for it anymore, or ever use it. So, I figured I'd give it a go.
  • Performed a whole clean uninstall/reinstall of ArcGIS Pro (renaming folders in the C: Drive and Registry as OLD) >> ArcPy STILL won't load

What I think I need to do is find a way to point to the correct path FIRST. But I can't find any documentation on what the correct path IS. OR, how to point to it. Could someone please help me?

0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @DS_GIS,

Can you use another IDE?  I prefer PyCharm, and there is a free community edition.  PyCharm gives you more capabilities than IDLE.  Below is a great document on how to configure PyCharm to use arcpy:

https://epjmorris.wordpress.com/2020/09/16/configuring-pycharm-for-use-with-arcgis-pro-and-arcmap/

0 Kudos
DS_GIS
by
Occasional Contributor

Hello Jake, 

Thank you so very much for your response! I seriously appreciate it. Unfortunately, not as this is for a school assignment and IDLE is required. I too prefer other IDE's. 

That said, my professor did send me a workaround. 

She figured out that multiple versions of IDLE are persisting post the uninstall/reinstall process. For me, those older versions are the ones pointing to the secondary installs of Python.

So, I had to go to the idle.exe located in this folder -- C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Scripts and run it directly from there. Then, IDLE will load arcpy. 

That said, I'd still like to know how to update the environmental variables and system paths for ArcGIS Pro as I couldn't find anything on this during my research. 

I did copy the correct system paths from the IDLE that is working well now. 

0 Kudos
MichaelVolz
Esteemed Contributor

Do you know why you have multiple versions of IDLE?  I think I encountered a similar issue trying to use IDLE on machines where I had cloned python for testing purposes and then upgraded ArcGIS Pro.  I would suggest performing a clean uninstall of ArcGIS Pro where you need to cleanup old directories and have to cleanup up registry settings.  I think there is an ESRI document on the clean uninstall procedure for ArcGIS Pro if you google it.

0 Kudos