[英]setup root folder in vs code in a python project
I have a project called hello , and path to this project is /home/Ubuntu/work/greetings/hello.我有一个名为hello的项目,该项目的路径是 /home/Ubuntu/work/greetings/hello。 my virtual environment named hello is created in /home/ubuntu/work/virtaul_environments/hello.
我的名为hello 的虚拟环境是在 /home/ubuntu/work/virtaul_environments/hello 中创建的。
My project structure is something like below:我的项目结构如下所示:
|-greetings
|-hello
|-hello_to_family
|-say.py
|-hello_to_friend
|-say.py
|-utils
|-utils.py
in above structure every say.py contains import from greetings folder.在上面的结构中,每个 say.py 都包含从 greetings 文件夹导入。
from greetings.hello.utils.utils import good_morning
Now the problem is my interpreter does not recognize greetings folder, it says现在的问题是我的解释器无法识别问候文件夹,它说
ModuleNotFoundError: No module named 'greetings'
My settings.json file contains:我的 settings.json 文件包含:
{
"python.pythonPath":"/home/ubuntu/work/virtual_environments/hello/bin/python"
}
Sorry if it is a naive question, I have just shifted to vs code from pycharm so I am getting bit of trouble with vs code.对不起,如果这是一个幼稚的问题,我刚刚从 pycharm 转移到 vs 代码,所以我在 vs 代码方面遇到了一些麻烦。
您必须将模块的路径附加到PYTHONPATH
:
export PYTHONPATH="${PYTHONPATH}:/home/Ubuntu/work/"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.