6

I just downloaded the PyCharm CE (community edition), but am having trouble opening it. When I launch the program, an error pops up saying:

python cannot be opened because of a problem.

When I click for more details regarding the problem, I get the following:

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x1] Library missing

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  dyld: No shared cache present
Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
  Reason: image not found

I have searched online for similar questions, but not been able to figure out what the problem is. My guess is that it might have something to do with dependency versions or something?

Mac Software: Mac OS Big Sure 11.1

Python Version: Python 3.9.1

I did not have this problem before updating my OS to Big Sur, perhaps this is part of what is causing the problem?

And advice, or links to helpful websites/resources would be greatly appreciated.

Edit: This problem only occurs when I click to start a new project in PyCharm.

I have also tried reinstalling both Python and PyCharm, but this did not work.

Screenshot of error message:

enter image description here

Edit 2:

This is all that shows up when I go into preferences -> python interpreter

enter image description here

And the original paths for creating a new project:

enter image description here

Ethan
  • 876
  • 8
  • 18
  • 34
  • 1
    maybe you should ask `PyCharm` authors - or even send it to authors as issue. – furas Feb 06 '21 at 23:08
  • 2
    You should ask this kind of question on https://youtrack.jetbrains.com/issues Did you make sure you downloaded the latest PyCharm version for Mac? Did you also download and install the latest Python distribution? etc... – bad_coder Feb 07 '21 at 01:13
  • 1
    Could you please let us know what's the output of `python -V` and `python3 -V` ? – DhakkanCoder Feb 11 '21 at 03:34
  • 1) 3.7.4 2) 3.9.1 – Ethan Feb 11 '21 at 04:26

3 Answers3

9

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.

jtc
  • 141
  • 3
  • 1
    For your setup to work, you need two things: (1) a working copy of Python and (2) PyCharm to use that copy. It sounds PyCharm is pointed at the Python version you want, but the Python version itself is still broken. I'd download a new copy of Python 3.9 and reinstall it. – jtc Feb 14 '21 at 23:49
  • I have already done this, that is the problem. I am running a new copy of both PyCharm and Python. – Ethan Feb 15 '21 at 01:02
  • 1
    In that case, let's try a deeper dive into why Python is broken. In Terminal, if you run `ls -l /usr/local/bin/python3*`, you'll get a lot of information about the python files on your system. On mine, python3 and python3.9 are just links (they have permissions "lrwxr-xr-x", note the leading "l"). Checking the directory they point to, `ls -l /Library/Frameworks/Python.framework/Versions/3.9/bin/python*` (leave off the "../" stuff in this case), shows that python3 is a link to python3.9, and python3.9 is an actual executable file: "-rwxrwxr-x". What are you seeing? – jtc Feb 15 '21 at 19:29
1

Before, I met the same problem.

You can try this

1.

cd /Users/${UserName}/Library/Preferences/PyCharm2019.3/

Here, modify the Pycharm2019.3 according to your version.

2.

rm -f pycharm.vmoptions

Relaunch the Pycharm.

Frank
  • 1,151
  • 10
  • 22
1

Big Sur is pretty new, so what you can do is reinstall Python and reinstall PyCharm. This can also be compatibility issues. If nothing works you can file a bug.