无法导入本地模块

发布于 2025-01-17 06:57:40 字数 296 浏览 3 评论 0原文

所以我试图在我的计算机上使用这个存储库,但我似乎无法导入本地模块(Agent.pyx)并使用该文件中的函数。我得到的错误是: ModuleNotFoundError:没有名为“RLAgent.Agent”的模块 错误屏幕截图 存储库链接

So I am trying to use this repository on my computer but I cant seem to import a local module (Agent.pyx) and use functions from that file. The error I get is:
ModuleNotFoundError: No module named 'RLAgent.Agent
Screenshot of error
Link to repository

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

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

发布评论

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

评论(2

感情废物 2025-01-24 06:57:40

您必须手动安装软件包

You have to install the package manually

最好是你 2025-01-24 06:57:40

由于 Agent.pyx 是一个 .pyx 文件,因此您需要首先构建它。链接存储库中的自述文件也提到了这一点。因此,您需要移至 RLAgent 目录并执行设置指令,如下所示:

cd RLAgent
python3 setup.py build_ext --inplace

这将构建所需的 .c.so 文件,然后将其导入到其他文件中例如 Train.py ,这是导入抛出错误的地方。

Since Agent.pyx is a .pyx file, you will need to first build it. The README file in the linked repo also mentions this. So you need to move to the RLAgent directory and execute the setup instruction as:

cd RLAgent
python3 setup.py build_ext --inplace

This will build the required .c and .so file which will then enable it's import in other files such as Train.py which is where the import is throwing an error.

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