NovFora Dev

How to fix import errors on Windows?

Liam Jackson

Liam Jackson

4 months ago

I keep getting ModuleNotFoundError even after installing the package

Stella Cook

Stella Cook

4 months ago

The #1 cause of this is multiple Python installations conflicting with each other. Here's how to isolate and solve it:

Diagnose first: run where python in your terminal. If you see two or more paths, your environment variables are pointing at the wrong one and that's why pip installs aren't appearing where you expect them.

The real fix — virtual environments: Stop installing packages globally. Create a per-project environment:

# Create the env
python -m venv .venv  # Use 'py -3.x -m venv' to pick specific version

# Activate it (Windows PowerShell)
.\.venv\Scripts\Activate.ps1  # Might need Set-ExecutionPolicy RemoteSigned first

Now pip install will put everything inside .venv/lib/site-packages, isolated from the rest of your system and other projects. This is literally what venvs were

Avery Rodriguez

Avery Rodriguez

4 months ago

Read the first post. Then read it again, more slowly this time. If you still can't figure out that the issue is your PATH environment variable being a dumpster fire, search 'python import sys path windows' in whatever forum you get your answers from — there are probably three hundred threads

Join the conversation to leave a reply.

Sign in to reply

Related topics