Overview
I have a VSCode workspace which contains two directories. In one is my main application, in another is a common package used by this application and a couple of others. # main-app.code-workspace
"folders": [
{
"path": "."
},
{
"path": "../common/shared_package"
}
],
I am able to import classes from the shared package if I manually type out the import string (from shared_package.utils.clock import SuperClock), but VSCode's quick-fix isn't offering any help with this.
- Imports from other dependencies typically work with quick-fix (eg if I type
trioI get an Auto-Import suggestion from VS Code) - Imports from within main-app also work fine with quick-fix
- Manually typing out the import to pull in classes from shared_package is fine
- Quick fix does not work with shared_package classes
Additional Info
- This is a Python project which uses Poetry for dependency management
- my pyproject.toml file includes this line
[tool.poetry.dependencies]
shared-hub-be = { path = "../common/shared_package", develop = true }
- I think it might be a red herring, but I am seeing this error (and only this error) in output when I open VSCode
2024-08-01 10:50:48.793 [error] Error: spawn pixi ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn pixi',
path: 'pixi',
spawnargs: [ '--version' ]
}
"python.languageServer": "Pylance"is set in workspace file
What have I tried so far
I did what any of us would do and spent 6 months manually typing out the import statements.Beyond that I tried some back and forth with ChatGPT - it suggested
- Add the following to both my VSCode settings file and the Workspace settings file.
"python.analysis.extraPaths": ["../common/shared_package"]
- Update PYTHONPATH to include
/absolute/path/to/common/shared_package - Try removing develop=true and then rerunning
poetry install
None of this stuff helped and has now been reverted.

shared_packagecan be installed bypip, and you have a virtual environment, you can install it in editable mode withpip -e.from .import shared_package.utils.clock. Does using relative import like this solve the problem? You need to make sure that the environment of the interpreter you are currently selecting hasshared_packageinstalled.from shared_package.utils.clock import SuperClock. Manually typing it is fine and always has been. My problem is that quick fix is seemingly not aware of the package and so does not suggest importing from it when a class isn't found. @darda, I'm using poetry which installs packages as editable whendevelop = trueis set in pyproject.toml as it is here. See: github.com/python-poetry/poetry/issues/…