gpt4 book ai didi

python-3.x - Pydev 显示 Unresolved 导入,但脚本运行?

转载 作者:行者123 更新时间:2023-12-02 11:26:26 25 4
gpt4 key购买 nike

我正在使用 PyDev。

我正在尝试将我的项目类组织到包中。

例如在一个文件夹中,我有一个模块/libraries/fund_price_library.py

在我的项目中的另一个文件中,我尝试使用以下方式导入:

from libraries.fund_price_library import FundPriceLibrary as fpl

PyDev 用红色下划线“FundPriceLibrary as fpl”,并用此错误标记它:

unresolved import fpl

但是,我的脚本运行得很好,所以我相信我的导入是正确的。

我的项目中有很多类似的错误,而且看起来很困惑。但是,我的 python 代码可以工作,所以我假设我导入正确。

如何抑制这些错误?

最佳答案

This question可能会解决您的问题。

In the properties for your pydev project, there's a pane called "PyDev - PYTHONPATH", with a sub-pane called "External Libraries". You can add source folders (any folder that has an init.py) to the path using that pane. Your project code will then be able to import modules from those source folders.

可能只是 PyDev 不知道在哪里可以找到这些文件。

关于python-3.x - Pydev 显示 Unresolved 导入,但脚本运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19200312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com