The short answer: upgrading to Big Sur may have broken your old Python installation, but your project in PyCharm is still trying to use it. The fix (on PyCharm 2020.3):
- Download and install a fresh installation of Python (in my case, Python 3.9)
- In PyCharm, in your project, go to Preferences... -> Project: YourProject -> Python Interpreter
- Open the dropdown next to the Python version the project's currently set to, and click "Show All..."
- Click "+" in the lower left to add a new Python Interpreter / virtual environment
- In the "Add Python Interpreter" window that opens, open the dropdown next to "Base Interpreter" and select the version of Python you just installed
- You will also likely need to click the folder icon next to "Location:" and make a new Location that doesn't end in "/venv". (In my case, since I'm using Python 3.9, I made a new folder called "venv_3.9".)
That should fix things for your current project. To fix it for new projects:
- File -> New Project Settings > Preferences for New Projects...
- Select Python Interpreter
- Make sure the Python Interpreter is either "No interpreter" or your newly-installed interpreter.
The Odyssey:
I was using Python 3.5 before the upgrade. My Python Console in PyCharm was showing an error loading a library from
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
A bit more investigation showed there was no file or directory at that location.
Running
/usr/local/bin/python3
from the Terminal generated the same error: it looks like the upgrade to Big Sur removed one or more libraries the Python 3.5 installation was using.
I closed Terminal. (This step is important because the Python installer will try to update the path information in Terminal, but, unless you want to do some command line magic, Terminal only reads the path when it first starts running.)
Python 3.5 is no longer available for download, so I downloaded Python 3.9.1 and installed it (and ran the command to install the extra certificates -- see the ReadMe file that comes with the installation for details).
Then I launched Terminal again, ran
/usr/local/bin/python3 --version
(NOT the same as the file at /usr/bin/python3) and
/usr/local/bin/python3.9 --version
and verified that Python 3.9 started and successfully printed its version for both commands. Running "which python3" also confirmed that the installer had updated my path to point to Python 3.9:
$ which python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
At this point, PyCharm was still throwing the "Python cannot be opened" errors.
The next step was to notice that the status bar at the bottom of the open project window still showed "Python 3.5", the broken version.
Either clicking the "Python 3.5" and selecting "Add Interpreter..." or going through "Preferences... -> Project: YourProject -> Python Interpreter" as described above will eventually let you add a new interpreter.
In the "Add Python Interpreter" dialog, I used the dropdown next to "Base Interpreter" to select /usr/local/bin/python3.9 (which was above the entry for python3.5; you may have to scroll up to see it). "OK" was still dimmed until I clicked the folder next to the "Location" entry and made a new folder for the new Python virtual environment. After clicking "OK", the PyCharm errors settled down.
Last step: keep the problem from happening again. According to the Jet Brains Docs, you can set the default Python interpreter by going to File -> New Project Settings > Preferences for New Projects... There, you can select Python Interpreter to see the default interpreter for new projects. The important thing here is to make sure it's not still pointed at a broken interpreter so any new projects you create won't start throwing errors again.