Skip to content
Advertisement

Is there a way to get VSCode to automatically use the closest Pipfile/pipenv?

E.g. for mono-repos with many python projects in them, it would be really nice if the linter, debugger, etc. would all look for packages specified in closest Pipfile.

E.g.

  • /
    • foo-package
      • Pipfile (Pipfile-A)
      • Pipfile.lock
      • script.py (when this file is open, use Pipfile-A for module resolution)
    • bar-package
      • Pipfile (Pipfile-B)
      • Pipfile.lock
      • script.py (when this file is open, use Pipfile-B for module resolution)

Is anything like this possible? Or is this a feature request for something that isn’t currently possible? Is it a crazy/bad idea?

Advertisement

Answer

This is a good idea, it can make the project clear.

Currently, VSCode does not support such a function, but you can try to use a virtual environment to install the required modules in different environments (for example: Python third-party packages, linter, etc.). When we choose a certain environment, we can use the modules in it. Even if it is the same file, we can use different modules in different environments. We only need to switch the virtual environment.

In addition, we have submitted this suggestion, and you can vote in this link, and we look forward to the realization of this feature.

Reference: Environment in VSCode.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement