在python ctypes中安装Pytork时出现问题。CDLL(dll)OSError:[WinError 126]找不到指定的模块

2024-04-20 00:43:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从https://github.com/CSAILVision/places365运行run_placesCNN_basic.py代码。 我正在运行Windows10和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, if you prefer to suppress this warning, 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模块,即使我已经安装了它吗


Tags: installpiptoinpyhttpskbfuture