简体   繁体   中英

VSCode not setting PYTHONPATH in workspace in WSL mode in windows

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM