最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - ImportError: cannot import name 'Tensor' from 'torch' (unknown location) - Stack Overfl

programmeradmin2浏览0评论

I’m trying to import Tensor from PyTorch:

from torch import Tensor

but I keep getting this error:

ImportError: cannot import name 'Tensor' from 'torch' (unknown location)

What I’ve Tried:

  1. Checked that PyTorch is installed (pip show torch), and I’m using version 2.5.1.
  2. Reinstalled PyTorch:
    pip uninstall torch
    pip install torch
    
  3. Tested the import in a Python shell, but the error persists.

Environment:

  • Python version: 3.10
  • PyTorch version: 2.5.1
  • OS: Windows 10
  • Virtual environment: Yes

How can I fix this issue?

发布评论

评论列表(0)

  1. 暂无评论