Search code examples
pythonvisual-studio-codepylance

Pip-install with "-e" flag and VSCode module-import warnings?


Using Python-3.11, I have a small utility package (ph_units) that is needed by a new main package I am developing. I am using pip install -e during development to pull in that dependency while I'm working. I am using python3 -m venv venv to create virtual environments for all of this work.

This all works great, and any changes to the ph_units utility package update properly in my main package as I go. Everything runs properly with no errors or issues.

However:


Even though it runs fine, I am getting warnings in my VS-Code environment about Import could not be resolved, and I do not get any type-hinting or autocomplete for any of my utility objects when working in my main package.

VS-Code Import Error

I suppose this makes sense, as the utility package is not actually in the venv/lib/python3.11/site-packages/ folder, but instead just the editable finder references are actually in there.

But I wonder if there is a known workaround to get proper VS-Code type-hints, autocomplete, and to avoid having VS-Code telling me there are errors when using the -e flag with pip install?

Environment:

  • Python 3.11
  • MacOS Monterey 12.5.1
  • VS Studio Code - Insiders v1.84.0

Solution

  • You can try to add the following codes to your settings.json to gain intellisense:

      "python.analysis.extraPaths": [
        "path/to/your/package"
      ],