Python 在Tkinter中找不到PIL模块

Python 在Tkinter中找不到PIL模块,python,tkinter,python-imaging-library,python-import,Python,Tkinter,Python Imaging Library,Python Import,当我尝试如下图所示导入PIL时,它会向我显示一条错误消息(如下所示) 代码: from tkinter import * #import tkinter as tk from PIL import ImageTk, Image root = Tk() root.title('Title here') root.iconbitmap('images/logo.ico') root.mainloop() Traceback (most recent call last): Fil

当我尝试如下图所示导入PIL时,它会向我显示一条错误消息(如下所示)

代码:

from tkinter import *

#import tkinter as tk

from PIL import ImageTk, Image

root = Tk()

root.title('Title here')

root.iconbitmap('images/logo.ico')

root.mainloop() 
Traceback (most recent call last):
  File "d:/College/Sem4/Human Computer Interaction/Full project/code here/Home.py", line 2, in <module>
    from PIL import ImageTk, Image
ModuleNotFoundError: No module named 'PIL'
错误消息:

from tkinter import *

#import tkinter as tk

from PIL import ImageTk, Image

root = Tk()

root.title('Title here')

root.iconbitmap('images/logo.ico')

root.mainloop() 
Traceback (most recent call last):
  File "d:/College/Sem4/Human Computer Interaction/Full project/code here/Home.py", line 2, in <module>
    from PIL import ImageTk, Image
ModuleNotFoundError: No module named 'PIL'
回溯(最近一次呼叫最后一次):
文件“d:/College/Sem4/Human-computerinteraction/Full project/code here/Home.py”,第2行,在
从PIL导入ImageTk,图像
ModuleNotFoundError:没有名为“PIL”的模块
注意:

from tkinter import *

#import tkinter as tk

from PIL import ImageTk, Image

root = Tk()

root.title('Title here')

root.iconbitmap('images/logo.ico')

root.mainloop() 
Traceback (most recent call last):
  File "d:/College/Sem4/Human Computer Interaction/Full project/code here/Home.py", line 2, in <module>
    from PIL import ImageTk, Image
ModuleNotFoundError: No module named 'PIL'
  • 我的系统上安装了Pillow 8.2.0
  • 我也试过做“pip安装映像”和“导入映像”的事情,但也没有成功

打开cmd并运行以下命令:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

这回答了你的问题吗?好的,转到cmd并运行命令
python3
,它说的是什么版本?-当我以“python3-m pip insta”的形式运行命令时,它说:“找不到Python;在没有参数的情况下运行以从Microsoft应用商店安装,或者从设置>管理应用程序执行别名禁用此快捷方式。”因此,我以“Python-m pip insta”的形式运行命令它说:它说“已经满足的要求:c:\users\ng\anaconda3\lib\site软件包中的枕头”,并给出了我系统中各个项目的版本号。在本例中:pip:(21.1)Pillow:(8.2.0)当我键入python3时,它带我到Microsoft应用商店,当我键入python--version时,它显示:python3.8.5确定您使用的编辑器是什么?Visual Studio代码