Why do I get Import "llama_index.xxx" could not be resolved
in VS Code even though I installed it?
I’m using Python 3.11.8 in a virtual environment.
I installed llama-index
and llama-parse
successfully via pip.
My code runs fine, but in VS Code I get warnings for every import:
Import "llama_index.llms.ollama" could not be resolved
Import "llama_parse" could not be resolved
...
Example:
from llama_index.llms.ollama import Ollama
from llama_parse import LlamaParse
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, PromptTemplate
How can I fix this?
This error is from VS Code’s Pylance, not Python.
It happens because VS Code is looking at a different Python environment than the one where you installed the packages.
Open a terminal inside VS Code, activate your venv, and run:
# Linux / Mac
which python
# Windows
where python
python -m pip show llama-index llama-parse
If they’re missing, install them in that environment:
python -m pip install llama-index llama-parse
Ctrl + Shift + P
(or Cmd + Shift + P
on Mac).venv
or env
folder.Ctrl + Shift + P → Developer: Reload Window
Or disable and re-enable the Python extension.
python -c "import llama_index; import llama_parse; print('All good!')"
If it prints “All good!”, your runtime is fine — the warning was just an IntelliSense environment mismatch.
💡 Summary:
Your imports are correct, but VS Code was using the wrong Python environment.
Once you install the packages in the correct interpreter and select it in VS Code, the warnings will go away.