我已经按照他们网站上建议的方式在虚拟环境 (env) 中通过 pip 安装了 Pytorch 和 Torchvision,虽然在我的 python 代码中导入 torchvision 时安装过程中没有发生错误,但会发生以下错误。
Traceback (most recent call last):
File "demo.py", line 2, in <module>
import torchvision
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/__init__.py", line 2, in <module>
from torchvision import datasets
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
from .fakedata import FakeData
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
from .. import transforms
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
from .transforms import *
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
from . import functional as F
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in <module>
from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/Users/QuinceyBee/env/lib/python3.7/site-packages/PIL/__init__.py)
我尝试创建新的虚拟环境以从头开始重建,尝试在 conda 环境中通过 conda 安装,但是,这些都没有解决这个问题。
对于任何格式问题,我深表歉意,这是第一次在这里发帖,而且我对使用 python 还比较陌生。
任何帮助将不胜感激。