PyCharm 找不到子模块,但控制台找到了

发布于 2025-01-17 18:57:39 字数 563 浏览 2 评论 0 原文

我无法正确访问 pycharm 中的子模块。假设我有

import numpy as np

,然后我尝试通过 np.testing.assert_all_close() 访问测试子模块。代码运行,但 pycharm 不会识别 testing 子模块,也不会执行任何类型的自动完成。但是,如果我像这样导入,它会起作用:

import numpy as np
import numpy.testing

然后它会像 np.testing... 一样工作。以前没有发生过这种情况,也许是翻译问题?我使用诗歌作为环境:

https://plugins.jetbrains.com/plugin/14307-poetry

如果我使用相同的环境打开 iPython 控制台,则没有问题,自动完成功能完美运行。

I cannot properly access submodules in pycharm. Let's say I have

import numpy as np

And then I tried accessing the testing submodule as np.testing.assert_all_close(). The code runs, but pycharm will not recognise the testing submodule, or do any kind of autocompletion. If I import like this however, it works:

import numpy as np
import numpy.testing

Then it works as np.testing.... This did not happen before, maybe it is an interpreter issue? I am using poetry as environment:

https://plugins.jetbrains.com/plugin/14307-poetry

If I open an iPython console using this same environment, there is no issue, autocomplete works perfectly.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文