I am taking the Python for Everyone course, at Step 4, Run a script in Python and am getting the following error:
ImportError: No module named arcpy
I did see that students had this issue back in 2015. Not sure if the move to ArcGIS Pro is the issue here as I don't even have that open and am working in PyCharm (downloaded this morning).
Script and error message:
#import modules import sys import os print (sys.executable) print(sys.prefix) print("PYTHONPATH: " + os.environ["PYTHONPATH"]) print("sys.path:") print("\n".join(sys.path)) import arcpy #set workspace arcpy.env.workspace = r"C:\EsriTraining\Python\PythEveryone\RunningScripts\Polk_County\OregonPolk.gdb" #set up a describe object for each fc in geodatabase fcList = arcpy.ListFeatureClasses() for fc in fcList: desc = arcpy.Describe(fc) print (desc.spatialReference.name) print ("Script completed")
ERROR MESSAGE:
Traceback (most recent call last):
File "C:/EsriTraining/Python/PythEveryone/RunningScripts/Polk_County/SpatialRef.py", line 9, in <module>
import arcpy
ImportError: No module named arcpy
Your IDE is probably tied to a different library. It can become a bit of a nightmare.
I'd suggest either running the code in an ArcGIS Pro or arcmap python window, or right-clicking on your .py file and selecting 'Open with IDLE ArcGIS Pro' or similar.
Are we right-clicking on SpatialRef.py? In PyCharm or within a file explorer window? Either way, I don't have the option to Open with IDLE ArcGIS Pro.