1

Recently, code analysis tools like PyCharm and Pylance in VSCode are not picking up packages installed in editable mode (pip install -e <package_name>).

This made it so I could not navigate to imported modules by Ctrl-clicking (in VSCode), and it is not providing me docstrings for imported functions.

I noticed that where in my site_packages directory there used to be a file with the package's name, now there is only a file called __editable_package_name_finder.py instead.

ini
  • 175
  • 9

1 Answers1

2

setuptools has changed the way it carries out editable installs which seems to have broken compatibility with various tools. For an in-depth explanation of the behavior refer to this page.

Setuptools provides a config option to stick to the old installation method. Either by setting the following flag on install: pip install -e . --config-settings editable_mode=compat

Or by setting the environment variable SETUPTOOLS_ENABLE_FEATURES="legacy-editable" before installing, though this last method has the limtation explained in the note here:

Newer versions of pip no longer run the fallback command python setup.py develop when the pyproject.toml file is present. This means that setting the environment variable SETUPTOOLS_ENABLE_FEATURES="legacy-editable" will have no effect when installing a package with pip.

After reinstalling the desired package using legacy mode, you will probably need to either restart the editor, or in the case of VSCode run the command "Python: Restart language server" in Ctrl+Shift+P

phd
  • 82,685
  • 13
  • 120
  • 165
ini
  • 175
  • 9