微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在python中安装pytorch的问题-ctypes.CDLLdll-OSError:[WinError 126]找不到指定的模块

如何解决在python中安装pytorch的问题-ctypes.CDLLdll-OSError:[WinError 126]找不到指定的模块

我正在尝试从https://github.com/CSAILVision/places365运行run_placesCNN_basic.py代码。 我正在运行Windows 10和Python 3.7.9。

我打开命令提示符并尝试安装pytorch:

py -m pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

我得到以下过程:

C:\Users\..\Downloads\places365-master>py -m pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.6.0+cpu
  Downloading https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp37-cp37m-win_amd64.whl (167.7 MB)
     |████████████████████████████████| 167.7 MB 1.8 kB/s
Collecting torchvision==0.7.0+cpu
  Downloading https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp37-cp37m-win_amd64.whl (362 kB)
     |████████████████████████████████| 362 kB 345 kB/s
Collecting numpy
  Downloading numpy-1.19.1-cp37-cp37m-win_amd64.whl (12.9 MB)
     |████████████████████████████████| 12.9 MB 63 kB/s
Collecting future
  Downloading future-0.18.2.tar.gz (829 kB)
     |████████████████████████████████| 829 kB 3.3 MB/s
Collecting pillow>=4.1.1
  Downloading Pillow-7.2.0-cp37-cp37m-win_amd64.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 42 kB/s
Using legacy setup.py install for future,since package 'wheel' is not installed.
Installing collected packages: numpy,future,torch,pillow,torchvision
  WARNING: The script f2py.exe is installed in 'C:\Users\..\AppData\Local\Programs\Python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or,if you prefer to suppress this warning,use --no-warn-script-location.
    Running setup.py install for future ... done
  WARNING: The scripts convert-caffe2-to-onnx.exe and convert-onnx-to-caffe2.exe are installed in 'C:\Users\..\AppData\Local\Programs\Python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or,use --no-warn-script-location.
Successfully installed future-0.18.2 numpy-1.19.1 pillow-7.2.0 torch-1.6.0+cpu torchvision-0.7.0+cpu
WARNING: You are using pip version 20.1.1; however,version 20.2.2 is available.
You should consider upgrading via the 'C:\Users\..\AppData\Local\Programs\Python\python37\python.exe -m pip install --upgrade pip' command.

最后,我试图运行.py文件

C:\Users\..\Downloads\places365-master>py run_placesCNN_basic.py
Traceback (most recent call last):
  File "run_placesCNN_basic.py",line 6,in <module>
    import torch
  File "C:\Users\..\AppData\Local\Programs\Python\python37\lib\site-packages\torch\__init__.py",line 81,in <module>
    ctypes.CDLL(dll)
  File "C:\Users\..\AppData\Local\Programs\Python\python37\lib\ctypes\__init__.py",line 364,in __init__
    self._handle = _dlopen(self._name,mode)
OSError: [WinError 126] The specified module Could not be found

有人知道为什么即使已经安装了pytorch模块也无法运行吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。