0

I’m on Windows 11 and originally had two Python installations: 3.14 and 3.9.
Both were installed and added to the PATH.

After setting up PyCharm 2025.2.4, I started getting this error when creating a virtual environment for Python 3.9:

Cannot set up a python SDK
at Python 3.14 (Python) (C:/Users/.../PycharmProjects/Python/.venv/Scripts/python.exe).
The SDK seems invalid.

When trying to create a venv manually:

python -m venv .venv
Error: Command '['...\Scripts\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

What I have already tried:

  • Removed Python 3.14 from PATH → deleted .idea, removed .venv → rebooted
    No effect. PyCharm still tries to use Python 3.14, even though it is no longer installed.

  • Completely uninstalled Python 3.14 → cleaned .idea, removed .venv → rebooted
    No effect. PyCharm still shows:

< Python 3.14 (Python)> C:\Users\...\PycharmProjects\Python\.venv\Scripts\python.exe

But this directory does NOT exist.

  • Uninstalled Python 3.9 as well → cleaned .idea → removed all venvs → rebooted → Installed Python 3.9 again on a clean system
    Still the same result — PyCharm keeps insisting on linking the project to Python 3.14, which no longer exists.

Additional details:

  • I deleted PyCharm caches:
    C:\Users\<USER>\AppData\Local\JetBrains\PyCharm2025.2.4\
    C:\Users\<USER>\AppData\Roaming\JetBrains\PyCharm2025.2.4\

  • I recreated the entire project in a new folder — PyCharm STILL automatically selects Python 3.14.

  • In the project structure I see:

External Libraries → Python 3.14 (Python)
C:\Users\...\PycharmProjects\Python\.venv\Scripts\python.exe

But this folder and interpreter do not exist at all.

Question:

Where could PyCharm be storing or retrieving the path to this phantom Python 3.14 interpreter, considering that:

  • Python 3.14 was removed from PATH

  • Python 3.14 was fully uninstalled

  • the project’s .idea folder was deleted

  • JetBrains caches were deleted

  • all virtual environments were removed

  • Python 3.9 was installed fresh on a clean system

And how can I completely remove any reference to this non-existent Python 3.14 interpreter so PyCharm stops trying to use it?

Update

I completely removed PyCharm, Python 3.14, Python 3.9, and all related files from the system. After that, I installed only Python 3.9.9, added it to PATH, and rebooted Windows.

To eliminate the possibility that the issue comes from PyCharm or project settings, I cloned my repository manually via terminal into a different folder, without any IDE involved.

Then I attempted to create a virtual environment directly from the Windows terminal:

python -m venv .venv

But I still get the exact same error:

Error: Command '['C:\\path\\to\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']'
returned non-zero exit status 101.

So the problem appears not to be related to:

  • PyCharm
  • .idea files
  • old project settings
  • Git

It seems to be something deeper in the system or related to how Python runs ensurepip on my machine.

Update:

The issue was caused by the space in my Windows username path. I was able to work around it by calling the Python interpreter using the short path (C:\Users*ALEXKA~1*...) instead of the full path with spaces. After that, creating virtual environments worked correctly.

2
  • Simply remove it from the list of configured Python interpreters in Pycharm (Settings -> Python -> Interpreter -> Python Interpreters -> Dropdown entry "Show All"). Commented Nov 16 at 11:42
  • I already tried that, unfortunately it doesn’t help. I removed the interpreter from: Settings → Python Interpreter → Show All project files: .idea/misc.xml, .idea/workspace.xml, *.iml (I manually set <component name="ProjectRootManager" project-jdk-name="Python 3.9" ... />) global JetBrains folders under %APPDATA% and %LOCALAPPDATA% and even reinstalled Python completely. The issue still persists, so it seems PyCharm is reading the invalid interpreter path from somewhere else. Commented Nov 16 at 14:39

2 Answers 2

1

I had an similar issue like this. In my case I removed pyhton version x like you. Installed a different python version and created a virtual environment in that new version.

First check what version you have in the cmd (command line)

python --version

To be sure that it is the 3.9 you installed.

Then create a new python virtual environment in the terminal window of PyCharm. Like this:

python3.9 -m .venv "<you_env_name"

That´s worked for me.

Sign up to request clarification or add additional context in comments.

3 Comments

Note that Python 3.9 is end of life, so installing it not a good idea.
You are right Robert actually the EOL already ended at October 31, 2025. But in my opinion if you know what are you doing and don´t use it in a productive or private unsaved situation. Why not.
Because most users who read it here often don't know what they are doing. Therefore it would be safer to say "Make sure you have at least"... and second remove the unnecessary Python version. Anyway your answer doesn't answer the question because this is a PyCharm configuration problem that tries to use non-existent venv, therefore creating a new one won't help.
0

The issue was caused by the space in my Windows username path. I was able to work around it by calling the Python interpreter using the short path (C:\Users*ALEXKA~1*...) instead of the full path with spaces. After that, creating virtual environments worked correctly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.