该命令会输出类似 C:\Users\你的用户名\AppData\Local\pypoetry\Cache\virtualenvs\myproject-py3.12 的路径。在 macOS/Linux 上,路径通常在 ~/Library/Caches/pypoetry/virtualenvs/ 或 .venv 目录中。
Run this command in your terminal to force Poetry to build a .venv folder directly inside your current project root: poetry config virtualenvs.in-project true Use code with caution. Step 2: Rebuild the environment
This is a frustrating disconnect because Pylance is the engine that powers VS Code's advanced Python features, so an unresolved import hobbles your development environment. pylance missing imports poetry link
Pylance will instantly detect the local .venv directory, parse the packages, and clear the missing import errors. Solution 2: Point VS Code to Poetry’s Global Cache Path
If you don't see it, select and paste the path to your Poetry environment (find this by running poetry env info --path in your terminal). Solution 2: Point VS Code to Poetry’s Global
This tells Pylance: "When searching for imports, also look inside the src folder."
"venvPath": ".", "venv": ".venv", "extraPaths": ["src"] parse the packages
If you’ve added a new package but not run poetry install , Pylance won’t see it. Always run:
当 Poetry 项目的结构比较复杂(如依赖本地开发的包、使用 monorepo 管理多个项目等),仅切换解释器可能还不足以让 Pylance 找到所有导入时,可以通过显式配置搜索路径来解决。