Problem
PyCharm cannot use the Python interpreter. Selecting or creating an interpreter shows:
Invalid Python SDK
Cannot set up a python SDK
at uv (<interpreter_name>) (/Users/username/PyCharmProjects/<project_name>/.venv/bin/python).
The SDK seems invalid.
You may also see spurious errors on standard-library imports, such as ModuleNotFoundError: No module named 'os' on a plain import os. Both symptoms have the same root cause.
How to confirm
This article applies only when a bundled IDE helper script fails to run. Locate idea.log (via Help | Show Log in…) and look for a Python error raised inside a file under the IDE's helpers directory:
Error: File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/syspath.py", line 2
import sys
^
IndentationError: unexpected indent
Exit code: 1
A Python syntax error such as IndentationError inside a JetBrains helpers/*.py file means a file that ships valid was changed on disk. That is the case this article covers. If idea.log points to a different reason for the invalid SDK (a broken virtual environment, a missing pyvenv.cfg, a uv error, and so on), this article does not apply.
The exact path depends on the edition and OS: plugins/python-ce/helpers/... in the free PyCharm, and plugins/python/helpers/... in PyCharm Professional and other IDEs that bundle the Python plugin, such as IntelliJ IDEA Ultimate and DataSpell. Note that "Repair IDE" and "Invalidate Caches / Restart" do not fix this, because they do not re-extract plugin files.
Cause
A bundled file inside the IDE installation directory was altered or truncated, so the IDE can no longer run its own helper scripts. The usual triggers are:
- Antivirus or endpoint-protection software quarantining or "cleaning" files inside the installation directory.
- An interrupted or incomplete IDE update, or a disk error.
- A file-sync or backup tool corrupting file contents or line endings (for example, a cloud drive or a restore from backup).
Resolution
Reinstall the IDE from scratch. You can use the Toolbox App to install and manage multiple instances (versions) of any JetBrains IDE independently.
To keep the problem from coming back, exclude the IDE installation directory and the directories the IDE uses for settings, caches, and logs from your antivirus or security software. See How to exclude IDE folders from the security scan..
Comments
0 comments
Please sign in to leave a comment.