win10下python3.8的PIL庫安裝過程
1.找到Python的位置
我的是在C:UsersadminAppDataLocalProgramsPythonPython38AppData這個文件是個隱藏文件需要查詢得先把隱藏文件顯示出來win10里面在Microsoft store 下載的Python我只找到了exe文件,所以就卸載然后重新下載過。去官網下載的時候下載速度極其慢,可以去這下:https://python123.io/download
2.PIL庫的安裝
PIL庫:具有強大的圖像處理能力在上面找到的位置,打開終端,然后輸入
pip install pillow
然后等待安裝就好了。這里提供參考代碼試驗有沒有裝成功。
from PIL import Image, ImageDraw, ImageFontdef add_num(img):draw = ImageDraw.Draw(img)myfont = ImageFont.truetype(’C:/windows/fonts/Arial.ttf’, size=40)fillcolor = '#ff0000'width, height = img.sizedraw.text((width-40, 0), ’99’, font=myfont, fill=fillcolor)img.save(’C:/Users/admin/Desktop/result.jpg’,’jpeg’)return 0if __name__ == ’__main__’:image = Image.open(’C:/Users/admin/Desktop/image.jpg’) add_num(image)
PS:windows下python3.8安裝PIL:python3.8缺少Image庫
python官網:https://www.python.org/
python3.8運行使用了Image庫的python腳本
運行.py腳本,報錯:Traceback (most recent call last):File “CutPngToTga.py”, line 32, in import PIL.ImageModuleNotFoundError: No module named ‘PIL’
這是因為,安裝的python還沒有包含PIL模塊。
python安裝PIL:進入windows的cmd:
1.更新pip(1)查看pip版本pip --version(2)更新pip
python -m pip install --upgrade pip
2.安裝python的PIL(python圖形庫)
pip install Pillow
3.python應用導入PILpython代碼中導入Image庫的一種方式:
import PIL.Image
總結
到此這篇關于win10下python3.8的PIL庫安裝的文章就介紹到這了,更多相關win10 python PIL庫安裝內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章:
