Has anyone seen this error... (ModuleNotFoundError)
I definitely ran pip install, but when I run it I get a ModuleNotFoundError. I checked the virtual environment and made sure the Python version matched, but I have no idea why this is happening. It works in VSCode but not in the terminal...
6 answers
This is so true lol I wasted half a day on this too
First, you need to check whether the pip you used for pip install is the same one as the Python you're currently running. Run pip -V and python -V, then compare the paths they show.
Try reinstalling with python -m pip install package-name. Using just pip often ends up pointing to the system pip. Also, run python -c "import sys; print(sys.executable)" to print the actual interpreter path, and it'll be immediately clear.
Got a source? No, wait—you need to post the full error log for anyone to answer. With just that one sentence, it’s all guesswork.
If it works in VSCode but not in the terminal, it’s almost 100% an interpreter path issue. Copy the Python path shown at the bottom of VSCode and compare it with which python in the terminal. If they’re different, that’s your answer.
Well, you said you checked the virtual environment, but it doesn’t quite add up that it works in VSCode... Couldn’t the virtual environment VSCode auto-activated be different from the one activated in the terminal? I’m not sure what exactly you mean by “checked” or how you checked it.