ModulenotFoundError:No模块名为' WebService'

发布于 2025-01-31 13:36:52 字数 314 浏览 3 评论 0 原文

即使在使用模块安装后,

pip3 install webservice

我仍然会得到错误modulenotfounderror:no模块名为“ WebService'”,

我确实使用了虚拟env。 使用pip3安装安装了所有必要的软件包

python3 server.py 

。 导入WebService.utils作为web_utils ModulenotFoundError:没有名为“ WebService.utils”的模块; “ WebService”不是包装

Even after installing the module using

pip3 install webservice

I still get the error ModuleNotFoundError: No module named 'webservice'

I did use a virtual env.
installed all necessary packages using pip3 install

python3 server.py 

gives: File "server.py", line 15, in
import webservice.utils as web_utils
ModuleNotFoundError: No module named 'webservice.utils'; 'webservice' is not a package

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痕至 2025-02-07 13:36:52

此错误: modulenotFoundError:无模块名为'WebService.utils';如果您将创建为 webservice.py 的主要程序文件命名为 python python webservice.py 或另一个文件在您运行程序的同一文件夹中具有名称 WebService.py 。 Python会将您的程序文件视为模块,并尝试在其中找到一些不在其中的东西。关于Python在哪里寻找模块,请参见 sys.s.path

在这种情况下,重命名您的程序文件,以使其名称与导入模块的名称不等。

This error: ModuleNotFoundError: No module named 'webservice.utils'; 'webservice' is not a package may also occur if you have named the main program file you created as webservice.py and try to run it as python webservice.py or another file has the name webservice.py in the same folder from which you run your program. Python will consider your program file as a module and try to find something in it that is naturally not in it. About where Python is looking for modules, see sys.path.

In this case, rename your program file so that its name does not equal with the name of the imported module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文