无法在conda中安装枕头6.2.1

时间:2020-08-30 17:10:46

标签: python pytorch python-imaging-library conda torchvision

升级pytorch / torch-vision后,发生以下错误:

python -c "import torch ; import torchvision as tv; print(torch.__version__, tv.__version__)
> "
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pointr/anaconda3/lib/python3.7/site-packages/torchvision/__init__.py", line 4, in <module>
    from torchvision import datasets
  File "/home/pointr/anaconda3/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/home/pointr/anaconda3/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/home/pointr/anaconda3/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/home/pointr/anaconda3/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/home/pointr/anaconda3/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' (/home/pointr/anaconda3/lib/python3.7/site-packages/PIL/__init__.py)

已注意到这是由于condapytorch 7.0.0 https://github.com/pytorch/vision/issues/1712之间的不兼容。所以我需要降级为pillow 6.2.1

为此发布的命令是:conda install pillow=6.2.1 -y

但是失败了:

 (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: | 

那是挂的。那么现在怎么办 ?解决方法本身需要一种解决方法。.conda是否已被torchvision破坏了?我首先使用conda的主要原因是torch / torchvision ..

更新 Conda尝试resolve conflicts。 20分钟之后,完成了13%。荒谬。这是2020年核心的i7迷你塔。没有一个理智的程序可以花费超过两位数秒的低时间来解决依赖关系。我终于杀死了它。我将尝试直接从pip开始的建议:

pip install Pillow==6.2.1 

好-是挂起 ..我要卸载pillow,然后用该版本重新安装。

另一项更新 @erip已推荐conda install -c conda-forge pillow=6.2.1-因此,我们开始:

conda install -c conda-forge pillow=6.2.1
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: \

我会让尘埃落在那一个上,但看起来不太可能。

1 个答案:

答案 0 :(得分:1)

对我唯一有用的是卸载/重新安装conda

https://docs.anaconda.com/anaconda/install/uninstall/

https://docs.conda.io/en/latest/miniconda.html

以下是选择安装的版本conda

(base) pointr@alienware:~/anaconda3$ python -c "import cv2; import PIL;print('cv2: ' + cv2.__version__); print('PIL: ' + PIL.__version__)"

cv2: 4.1.0
PIL: 7.1.2

(base) pointr@alienware:~/anaconda3$ python -c "import torch ; import torchvision as tv; print('torch:' + torch.__version__); print('torchvision: ' + tv.__version__)"

torch:1.3.1
torchvision: 0.4.2