将C.Py添加到简单的项目结果“ ModulenotFoundError:no Module”中。

发布于 2025-02-11 18:40:20 字数 488 浏览 1 评论 0原文

显然,不完全是新手,但也不是专家。在其他地方找不到这个问题。

这是一个使用原子创建的简单布局,它过去可以从终端工作正常,但由于模块c.py刚刚添加了,因此不再工作。此布局确实可以用作Pycharm项目。

这种布局本质上是有缺陷的,还是假设最简单的“ Hello World”功能在理论上可以起作用?

先感谢您。

 --blah
    |__blah
         |__a.py
         |__b.py
         |__c.py
#a.py
import b
import c

#do stuff
(venv)me blah $ python3
>>>import blah.a
ModuleNotFoundError: No module named 'c'

Not exactly a newbie but not an expert either, obviously. Could not find this problem elsewhere.

This is a simple layout created with Atom, and it used to work just fine from the terminal, but no more, since the module c.py has just been added. This layout does work as a PyCharm project.

Is this layout inherently flawed, or should it work in theory, assuming the simplest possible "hello world" functionality?

Thank you in advance.

 --blah
    |__blah
         |__a.py
         |__b.py
         |__c.py
#a.py
import b
import c

#do stuff
(venv)me blah $ python3
>>>import blah.a
ModuleNotFoundError: No module named 'c'

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

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

发布评论

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

评论(1

别再吹冷风 2025-02-18 18:40:20

在pycharm中,blah.blah被“标记为源”。搜索导致我进入这篇文章:是什么标记目录资料来源root“真的是吗?

意识到Pycharm在我认为是理所当然的幕后做了一些事情,我尝试了该项目的原子版本中的以下内容:

import blah.c

解决了问题。

因此,我推测对原始问题的严格答案是“否”。

In PyCharm, blah.blah is "marked as sources root". Searching that led me to this post: What does "Mark directory as sources root" really do?

Realizing that PyCharm did some things behind the scenes that I took for granted, I tried the following in the Atom version of the project:

import blah.c

which solved the problem.

Thus I surmise that the strict answer to the original question is, "no".

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