【问题标题】:I am trying to import torch-cpu in python 3.9 but get the following error我正在尝试在 python 3.9 中导入 torch-cpu,但出现以下错误
【发布时间】:2020-09-03 20:43:15
【问题描述】:

在尝试import torch-cpu 时,出现以下错误:

Traceback (most recent call last):   File "<pyshell#0>", line 1, in <module>
    import torch   File "C:\Users\Ravi\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)   File "C:\Users\Ravi\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application

如何解决这个错误?

【问题讨论】:

  • 嗨伙计,我认为这个链接可能会有所帮助,github.com/pytorch/pytorch/issues/27693
  • 嗨@Puspender Singh,如果您发现任何有帮助的答案,请将其标记为此类(问题左侧的灰色勾号)。也请考虑为有用的答案投票。

标签: python importerror torch oserror python-3.9


【解决方案1】:

正如 Akash 指出的那样,该问题可能与您的 Python 根文件夹在 %PATH% 中列出的顺序有关。可能存在前面提到的不同版本的 Python(本例中为 3.8)导致 Python 3.9 加载未为此版本安装的库(因此可能不兼容)。

要修复它,请将 Python 3.9 根目录设置为 %PATH% 上的第一个目录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    相关资源
    最近更新 更多