使用python setuptools entry_points导入其他文件 - 未命名的模块

发布于 2025-02-12 07:22:56 字数 632 浏览 1 评论 0原文

我不熟悉Setuptools,所以我希望这是一个简单的错误(但找不到任何相关的错误)。

我在我的setup.py

entry_points={
    'console_scripts':[
        'filea=autostart.filea:main'
    ]
}

和我的autostart.filea

from fileb import ClassName

中有此功能(filea和fileb都在autostart内部),

当我运行时,该工程文件在我的运行时

python autostart/filea.py

,而不是直接运行

filea 

二进制文件时。

在这种情况下,我

packages/autostart/filea.py", line 15, in <module>
    from fileb import ClassName
ModuleNotFoundError: No module named 'fileb'

会得到任何帮助,感谢您。

I am not familiar with setuptools so I hope this is a simple mistake (but couldn't find anything related).

I have this in my setup.py

entry_points={
    'console_scripts':[
        'filea=autostart.filea:main'
    ]
}

And my autostart.filea has

from fileb import ClassName

(filea and fileb are both inside autostart)

This works file when I run

python autostart/filea.py

but not when I run the

filea 

binary directly.

In this case I get

packages/autostart/filea.py", line 15, in <module>
    from fileb import ClassName
ModuleNotFoundError: No module named 'fileb'

Any help would be appreciated, thank you.

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

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

发布评论

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