VSCode not setting PYTHONPATH in workspace in WSL mode in windows

Viewed 211

I have a WSL (Ubuntu-20.04) and opening a VSCode in WSL mode. I am trying to create a project and folders inside them. I am not able to import the modules of the project. It is giving me "unable to import" pylint errors. Below is my folder structure

my_project
  |
  |- src
    |
    |- logger_utils
      |
      |- logger.py
    |- driver.py
  |- test

Inside my driver.py, if I try to import a method as from src.logger_utils.logger import get_logger, pylint raises a error - Unable to import

This is happening only in WSL mode. But the same is working fine in normal mode. Any fix/suggestions for this issue

1 Answers

This is probably a PYTHONPATH issue. In your VScode settings for your workspace, add the following:

"terminal.integrated.env.linux": {"PYTHONPATH": "${workspaceFolder}/src"},

You may need to restart VScode after as well.

Related