Pylance Missing Imports Poetry Hot -

The "Ghost" Imports: Why Pylance Can’t See Your Poetry Packages (And How to Fix It)

You’ve just scaffolded a pristine new project. You ran poetry add fastapi (or pandas, or numpy), the install finished without a hitch, and your pyproject.toml looks beautiful. You open VS Code, type import fastapi, and then you see it.

The dreaded wavy red underline. "Import could not be resolved." pylance missing imports poetry hot

Pylance is panicking. It claims your package doesn't exist. You check your terminal—poetry run python main.py works perfectly. So, why is your editor lying to you? The "Ghost" Imports: Why Pylance Can’t See Your

If you search for this issue, you’ll find it’s a "hot" topic in the Python community. The code works, but the developer experience is broken. Here is the breakdown of why this happens and the two-minute fix to get your IntelliSense back. Then, update your settings

Case 2: The "Editable Install" Trap (Dev Dependencies)

Poetry installs your own project in editable mode (pip install -e .). Pylance can sometimes fail to resolve local modules.

Fix: Ensure your pyproject.toml includes your project package correctly:

[tool.poetry]
name = "myproject"
packages = [include = "myproject", from = "src"]

Then, update your settings.json as shown above with python.analysis.extraPaths.

3.2 Recreate Your Environment

# Delete the old global env (optional but clean)
poetry env remove --all

🧪 Verification

  • Run poetry run python -c "import <package>" – works.
  • In VS Code, open a .py file, hover over import – no squiggles.
  • Check bottom-left interpreter indicator shows Poetry env.