from torchvision import transforms
出现报错
D:\anaconda\envs\PyTorch\lib\site-packages\torchvision\io\image.py:11: UserWarning: Failed to load image Python extension: Could not find module 'D:\anaconda\envs\PyTorch\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
warn(f"Failed to load image Python extension: {e}")
网上查到是版本不对, 直接
pip uninstall torchvision
然后
pip install torchvision
解决 torchvision 引起的 Python 扩展模块加载失败问题
在使用 PyTorch 的 torchvision 库时遇到了 UserWarning,提示无法加载 image Python 扩展模块。错误信息指出可能是 torchvision 的版本不匹配。为解决此问题,博主建议先通过 pip 卸载 torchvision,然后重新安装最新版本。执行 'pip uninstall torchvision' 后,再运行 'pip install torchvision' 完成更新。此方法通常能解决因 torchvision 版本问题导致的导入错误。
1万+





