attributeError:模块' tensorly'没有属性分解'

发布于 2025-02-06 01:34:02 字数 906 浏览 1 评论 0原文

我在Python上使用了一个软件包(Tensorly),在那里我无法访问所有模块。

例如,如果我尝试使用“分解”模块:

  • python版本:3.9.12
  • 张力版本:0.7

i运行:

pip3 install tensorly
python3 main.py 

main.py:

### imports ###
  
import tensorly

### tensor decomposition ###

cp = tensorly.decomposition.CP(n)

tougpy: outpty:

AttributeError: module 'tensorly' has no attribute 'decomposition'

ps:ps:当我转到/.local/lib/python3.9/site-site--软件包/张力是有模块分解,当我打印SYS.PATH时,有相同站点包装的路径。

我有另一个软件包的问题(Cobrapy)以及其他不同版本的Python(3.6)

更新:

现在我有Scikit-Learn:输出完全相同的问题

from sklearn.preprocessingcessing import StandardScaler 

No module named 'sklearn.preprocessingcessing' 

即使此软件包在.prepropocessingcessing之前确实运行良好),该错误今天也随机弹出...

I’m using a package (tensorly) on python where I don't have access to all the modules.

For example if I try to use the 'decomposition' module :

  • python version: 3.9.12
  • tensorly version : 0.7

I run :

pip3 install tensorly
python3 main.py 

main.py :

### imports ###
  
import tensorly

### tensor decomposition ###

cp = tensorly.decomposition.CP(n)

output :

AttributeError: module 'tensorly' has no attribute 'decomposition'

PS: When I go to /.local/lib/python3.9/site-packages/tensorly there is the module decomposition and when I print my sys.path there is the path for this same site-packages.

I have the same problem with another package (cobrapy) and on other different machines with other versions of python (3.6)

Update :

Now I have the exact same problem with scikit-learn:

from sklearn.preprocessingcessing import StandardScaler 

Output :

No module named 'sklearn.preprocessingcessing' 

Even if this package worked really well before (no error with .preprocessingcessing), this error popped out randomly today...

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

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

发布评论

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

评论(1

反目相谮 2025-02-13 01:34:02

您必须首先导入要使用的子模块,如果默认情况下未加载它(您可以检查__ INIT __。py文件以查看默认情况下导入哪些模块)。

换句话说,仅首先导入分解

import tensorly
import tensorly.decomposition

或直接导入要使用的分解方法:

from tensorly.decomposition import CP

您的Scikit-Learn示例中也有错字。

You have to first import the submodule you want to use if it isn't loaded by default (you can check the __init__.py file to see what modules are imported by default).

In other words, just first import decomposition:

import tensorly
import tensorly.decomposition

Or directly import the decomposition methods you want to use:

from tensorly.decomposition import CP

You also have a typo in your Scikit-Learn example.

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