我正在跟踪文档:https://pillow.readthedocs.io/en/stable/
我成功地用pip安装了枕头。但是,当我试图导入Image
函数时,我可以:
( a)只从PIL导入它)只获得没有模块PIL
c的错误,得到一个没有模块Pillow
的错误
下面是一个信息(当我尝试使用枕头而不是PIL时也会发生同样的事情):
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
这是我用pip安装的证据:
Requirement already satisfied: Pillow in c:\python310\lib\site-packages (8.4.0)
我在Stackoverflow上读到,PIL不再被维护。然而,毫无疑问地回答了我的问题:ImportError: No module named PIL
发布于 2021-11-03 09:31:27
您可能已经在不同于您使用的Python安装中安装了Pillow。pip
和python
是相互联系的。让我们确定您首先使用的命令。
Q1 -您使用什么命令来运行脚本?
启动Python脚本时使用什么命令?或者,如果您使用图形化的IDE,例如与代码、JetBeans、空闲,那么它使用什么命令来启动Python?
可能的答案:
所以,如果答案是python3
,那么在答案的其余部分,YOURPYTHON
将是python3
。
Q2 -您使用什么命令来安装包?
您使用什么命令来安装Python包?
可能的答案:
所以,如果答案是pip3
,那么在答案的其余部分,YOURPIP
将是pip3
。
您已经在Python310安装中安装了pip
,您可以在您的“满足需求”消息中看到这一点,或者通过运行:
YOURPIP -V # quick version check
YOURPIP show pillow # more detail as to location
YOURPIP debug # lots of detail about how pip is set up
现在的问题是,您使用的是哪一个Python?它在哪看?
YOURPYTHON -V # quick version check
YOURPYTHON -c "import sys; print(sys.executable)" # where is my Python interpreter?
YOURPYTHON -c "import sys; print('\n'.join(sys.path))" # where does it look for packages?
一般来说,如果您使用python
,您可能应该使用pip
。但是,如果您使用python3
,您可能应该使用pip3
来确保您正在安装的位置与您的解释器正在查找的位置相同。
当您键入这样的命令时,您可以获得有关实际运行的信息:
which python # works on macOS, Linux and Windows
type python # works on macOS and Linux and is preferable
发布于 2021-11-03 09:27:41
运行pip install image --user
,然后它就能工作了。
https://stackoverflow.com/questions/69822301
复制相似问题