Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Unresolved import with packages under "src" when installed as editable #1013

@eirikrye

Description

@eirikrye

A project I am working on is structured with all its packages under a src folder in the project/workspace directory.

I am using a local virtualenv for development (.venv/bin/python), and the package is installed in editable mode, meaning it should be available in sys.path for that Python interpreter.

However, Visual Studio Code fails to resolve any of the imports from these packages, throwing unresolved-import errors and missing autocompletes.

Autocomplete instead suggests importing src.mypackage, instead of simply mypackage.

I have tried various variations of python.autoComplete.extraPaths: ["${workspaceFolder}/src"], ["src"], ["./src"], restarting the language server after each change, but none appear to work.

I have attempted with the beta `downloadChannel as well, to no avail.

The Output tab prints the following:

Starting Microsoft Python language server.
[...]
[Info  - 1:45:13 PM] Python search paths:
[...]
[Info  - 1:45:13 PM]     /Users/rye/Documents/my-project/.venv/lib/python3.7/site-packages
[Info  - 1:45:13 PM]     /Users/rye/Documents/my-project/src
[Info  - 1:45:13 PM] Configuration search paths:
[Info  - 1:45:13 PM]     /Users/rye/Documents/my-project/src
[Info  - 1:45:13 PM] Microsoft Python Language Server version 0.2.62.0

This seems to suggest that the language server has detected the folder both in the Python installation's sys.path, as well as the configured python.autoComplete.extraPaths

How do I get the language server to resolve my imports properly?

Metadata

Metadata

Assignees

Labels

editable-installspip editable installs / setup.py develop

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions