Skip to content
Advertisement

How can i fix this error that occurs when I use arcpy in Pycharm?

first off let me state I am not a programmer. My knowledge of programming is occasionally using R to help with data at my job. Recently I have been attempting to use python in order to automate several ArcGIS functions.

JavaScript

I have been introducing myself to python and arcpy through different tutorials and I see this bit of code repeated often throughout those tutorials. However when I run this instead of “Finished with exit code 0” I have this mess.

JavaScript

Things I have done:

I have tried running a few simple lines of code (adding variables, printing variables ect) outside of arcpy and everything worked fine. I have checked the python interpreter and it is one located in arcgis so I’m fairly certain that is not the issue, especially since arcpy is not available using the other python interpreter path.

If anyone could help point me in the right direction It would be greatly appreciated. I just dont have enough experience with python and Pycharm to understand what is going wrong. Thanks.

Advertisement

Answer

I figured out how to make it work, but I am not entirely sure why…. If anyone could provide some clarification it would be appreciated. Until then I will explain to the best of my ability.

The Python interpreter I was using was C:Python27ArcGIS10.6 I thought that would work because after switching to it from the default, pycharm began to recognize ArcPy functions. Obviously that didn’t work.

While reading this Noticed that path they used and tried it on my computer. — https://community.esri.com/t5/python-documents/pycharm-setup-for-arcgis-desktop/ta-p/1125129

JavaScript

What works –> C:Program FilesArcGISProbinPythonenvsarcgispro-py3

So it seems that in order for it to work the interpreter has to be from the arcgispro-py3 folder located in your ArcGIS install. I don`t understand how this differs from the path I used first because both recognized ArcPy functions. Regardless I can confirm that the new path can execute the code with no exceptions.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement