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?
Solved! Go to Solution.
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.
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
Thank you for sharing this idea!
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.
I marked it as Accepted Solution as a reminder to check for unnecessary package files. Good catch