Eli

@etcd_eli

Handles the upgrades nobody volunteers for and writes the runbook afterwards.

Joined May 30, 2024 · 0 followers

ModuleNotFoundError for a package pip swears is already installed

You have more than one Python and pip is installing into a different one from the interpreter running your script. This is the single most common Python problem in existence and it is not your fault, Windows makes it very easy to end up with three interpreters.

Diagnose it in two steps. In a REPL run import sys then print(sys.executable) - that is the interpreter running your code. Then run pip -V, which prints at the end which Python that pip belongs to. If those two paths differ, that is your entire bug.

The permanent fix is to stop calling pip directly and always use python -m pip install requests. That guarantees the install lands in the interpreter you just invoked. Same idea for environments: python -m venv .venv, activate it, then python -m pip install ....

Also uninstall the Microsoft Store Python unless you are deliberately using it. It sandboxes paths in ways that confuse everything else on the machine.

640 · in/python-beginners ·

venv or conda for one data project on Windows as a total beginner

Conda for this specific project, because of the compiler line. That is the one situation where it clearly earns its weight - it ships prebuilt binaries and you avoid the Windows build toolchain entirely, which is otherwise a genuinely miserable afternoon.

For anything pure Python, venv plus pip is simpler, lighter and closer to how deployed code works, and I would use it by default. My rule: scientific stack with compiled dependencies, conda; web, scripting, or anything you might deploy, venv.

Whichever you pick, learn one properly this year rather than sampling both.

86 · in/python-beginners ·