简体   繁体   English

无法在 Python 中导入 mymodule

[英]Can't import mymodule in Python

I'm using VSCode and getting warning "search is not accessed in Pylance" when trying to import my own module, search is the name of the module I need to import to my main program我正在使用 VSCode 并在尝试导入我自己的模块时收到警告“在 Pylance 中未访问搜索”,搜索是我需要导入主程序的模块的名称

在此处输入图像描述

1- I do have __init__.py file on module folder 1-我在模块文件夹中有__init__.py文件

2- Tried changing interpreter 2-尝试更换口译员

Importing mymodule as below: from src import search导入 mymodule 如下: from src import search

folder structure:文件夹结构:

文件夹结构

Could the reason of this be that 'src' is being treated as a module instead of a folder?原因可能是“src”被视为模块而不是文件夹吗?

在此处输入图像描述

Is there an alternative way to import my modules?有没有其他方法可以导入我的模块?

Thanks谢谢

The error "search" is not accessed means you are not using search ,错误"search" is not accessed意味着您没有使用search

在此处输入图像描述

If you use search below then this error will go away.如果您使用下面的search ,则此错误将 go 消失。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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