由于需要使用Python操作圖檔,想使用sudo pip install PIL引入PIL(Python Imaging Library)庫,但是結果如下:
could not find a version that satisfies the requirement PIL.(form versions:)
No matching distribution found for PIL.
這個提示很費解,隻能去找度娘了,原來已經用Pillow代替了PIL,在使用方面沒有不同,API都是相同的。真是個挨千刀的,提示資訊裡怎麼不告訴我們這些剛學Python的小白呢,還得白忙活半天。既然這樣那就老老實實安裝Pillow吧。但是又發現Pillow需要依賴multiprocessing,是以必須先安裝multiprocessing。指令如下:
sudo pip install multiprocessing
接着再執行如下指令:
sudo pip install Pillow
引入子產品要按照下面的方式寫(注意大小寫)
第一種:from PIL import Image
第二種:from PIL.Image(用這種方式時,下面使用時也得寫成PIL.Image.open('1.png'),或者可以在引入時修改下子產品名,如from PIL.Image as image)
引入之後就可以正常使用了。
轉載于:https://www.cnblogs.com/suxianglun/p/9013043.html