Select to view content in your preferred language

PyCharm environment broke access to arcpy... help?!

89
4
Jump to solution
yesterday
AllenDailey1
Frequent Contributor

I seem to have broken arcpy by setting up an "environment" in a certain way in PyCharm.  Can anyone help me fix this, without having to uninstall and reinstall ArcGIS Pro?  (Reinstalling would mean I'd have to re-do a bunch of other settings on this machine.)

I know this documentation exists about setting up PyCharm for Pro, but I failed to double-check it today.  PyCharm Setup for ArcGIS Desktop - Esri Community

Instead of setting up an "existing environment" like the documentation says to, I chose "new environment," with "location" of C:\Program Files\ArcGIS\Pro\bin\Python\envs\argispro-py3 - apparently this was bad. For "interpreter," I selected the python.exe from that arcgispro-py3 folder.

Now when I run a script that worked perfectly on a different machine, I get error "No module named 'arcpy'".

When I double-click "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" in File Explorer and then type "import arcpy," I also get the same error.

Any ideas?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AllenDailey1
Frequent Contributor

I think I fixed it!

I was comparing the contents of C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3, on the broken machine vs. a machine where arcpy works.

I then noticed two files that were created today on the broken one, but do not exist on the good one. I deleted the files, then ran my script, and I didn't get the error!

The 2 files I deleted were:  .gitignore   and    pyvenv.cfg

I also deleted the PyCharm project I had created earlier.

View solution in original post

4 Replies
DanPatterson
MVP Esteemed Contributor

a long shot

Repair an environment—ArcGIS Pro | Documentation

you may have to repair the arcgispro install instead (when you go to "uninstall a program" there is a "repair" option which you should try first to see if it will just repair the ...arcgispro-py3 environment


... sort of retired...
AllenDailey1
Frequent Contributor

Thank you for sharing this idea!

0 Kudos
AllenDailey1
Frequent Contributor

I think I fixed it!

I was comparing the contents of C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3, on the broken machine vs. a machine where arcpy works.

I then noticed two files that were created today on the broken one, but do not exist on the good one. I deleted the files, then ran my script, and I didn't get the error!

The 2 files I deleted were:  .gitignore   and    pyvenv.cfg

I also deleted the PyCharm project I had created earlier.

DanPatterson
MVP Esteemed Contributor

I marked it as Accepted Solution as a reminder to check for unnecessary package files.  Good catch


... sort of retired...
0 Kudos