PyCharm error - Issues with the python interpreter

1124
2
01-25-2023 07:47 AM
WilsonIonara
New Contributor III

I am getting an error when I try to run my script in PyCharm as it is not recognizing arcpy. I think it has to do with the system interpreter or the conda interpreter. I have ArcGIS Pro 2.9 so the python version is 3.7. For the python interpreter on settings, I have Python 3.7 which is the correct one, but I think the problem is with the system interpreter. For the system interpret it is stuck n the C:\\Python311\python.exe and even if I change it as administrator it goes back to that python version. Maybe it is some kind of system variable from a previous version.

I see on command prompt that the python versions I have are different from the one installed by arcgisPro and I think this is the root of the problem

 

Pycharm6.PNGPycharm5.PNG

I am attaching images for my settings (the PyCharm version is 2022.3.1. Any help is appreciated! Thank you!

Pycharm1.PNGPycharm4.PNGPycharm3.PNGPycharm6.PNGPycharm2.PNG

Tags (3)
0 Kudos
2 Replies
by Anonymous User
Not applicable

You need to set the interpreter for the script that you are trying to run.  You can do this by clicking on the env name in the lower right corner of the window and selecting the interpreter. For example, I have Pro (3.9), the system's (3.11) and ArcMaps 2.7 for when I need 2.7.

ints.png

and then select the one that is mapped to your Pro install.

PS, you probably should clone your base python env instead of using the default env. Your cloned envs would be in your C:\Users\you\AppData\Local\ESRI\conda\envs directory.

0 Kudos
WilsonIonara
New Contributor III

I uninstalled ArcGIS Pro so that it would reinstall conda, then I deleted the old python version from the system variable path. I also reinstalled PyCharm, and also cloned an environment for ArcPro. Every time I tried to set the interpreter it would go back to the old version but doing all the steps I mentioned worked and now I have PyCharm working like a charm 🙂 Thank you for your answer!