相对模块在玛雅人使用Python进口

发布于 2025-02-03 14:12:00 字数 579 浏览 2 评论 0原文

我的默认设备Maya脚本文件夹中有一个软件包文件夹。例如(c:\ users \ username \ documents \ maya \ 2020 \ scripts \ packagefolder)。

该软件包基本上是这样的:

package/
  __init__.py
  Classes/
    ExampleClass.py
    __init__.py
  Utils/
    SomeUtilModule.py
    __init__.py

在我的 init .py文件中,我尝试导入这样的模块:

from package.Classes import ExampleClass

Maya说什么:

# Error: ImportError: file C:/Users/USERNAME/Documents/maya/2020/scripts\package\__init__.py line 5: No module named Classes # 

我在这里做错了什么?

I have a package folder located in my defaults maya scripts folder. E.g. (C:\Users\USERNAME\Documents\maya\2020\scripts\packageFolder).

The package is basically structured like so:

package/
  __init__.py
  Classes/
    ExampleClass.py
    __init__.py
  Utils/
    SomeUtilModule.py
    __init__.py

In my init.py file I try to import modules like so:

from package.Classes import ExampleClass

what Maya says:

# Error: ImportError: file C:/Users/USERNAME/Documents/maya/2020/scripts\package\__init__.py line 5: No module named Classes # 

What am I doing wrong here?

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

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

发布评论

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

评论(1

心不设防 2025-02-10 14:12:00

我怀疑这与Maya的实施无关,而是关于您的Python代码中的循环进口。可能,您的审查计划'__ init __. py从软件包导入。

您可以通过搜索“ Python循环进口”来阅读有关此内容的信息。不幸的是,错误描述不会显示问题的性质,如果您不知道事先的原因,就会非常困惑。

关于如何处理此问题有很多建议,仅举几例:一个< /a>,两个

I suspect it's not about Maya's implementation, it's about circular imports in your Python code. Probably, your ExampleClass' __init__.py imports from package.

You can read about this by searching for "Python circular imports". Unfortunately, the error description does not show the nature of the problem and is very confusing if you don't know the reason beforehand.

There are plenty of suggestions on how to deal with this, just to name a few: one, two.

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