[英]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.我有一个 WSL (Ubuntu-20.04) 并在 WSL 模式下打开一个 VSCode。 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.
它给了我“无法导入”的 pylint 错误。 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
在我的
driver.py
中,如果我尝试from src.logger_utils.logger import get_logger
方法,pylint 会引发错误 - Unable to import
This is happening only in WSL mode.这仅在 WSL 模式下发生。 But the same is working fine in normal mode.
但在正常模式下同样可以正常工作。 Any fix/suggestions for this issue
针对此问题的任何修复/建议
This is probably a PYTHONPATH issue.这可能是一个 PYTHONPATH 问题。 In your VScode settings for your workspace, add the following:
在工作区的 VScode 设置中,添加以下内容:
"terminal.integrated.env.linux": {"PYTHONPATH": "${workspaceFolder}/src"},
You may need to restart VScode after as well.之后您可能还需要重新启动 VScode。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.