我在 shell 中使用这个命令来安装 PIL:
easy_install PIL
我运行python
并输入以下命令:import PIL
。但是我遇到了下面的错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named PIL
我从未遇到过这样的问题,你认为是什么原因?
我在 shell 中使用这个命令来安装 PIL:
easy_install PIL
我运行python
并输入以下命令:import PIL
。但是我遇到了下面的错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named PIL
我从未遇到过这样的问题,你认为是什么原因?
pip install Pillow
注意:PIL已经被弃用,pillow是其继承者。
image
不是问题中的PIL模块,而是一个“Django应用程序”(它恰好是基于PIL的)。参考链接:https://github.com/francescortiz/image。 - Eric O. Lebigotpip install image
对我起了作用。感谢 DuckDuckGo 缓存保存了编辑前的答案! - Zahracmd
不区分大小写,但写法上有什么首选方式吗? - Josiah Yoderpip install image
对我有用。 - Joseph Yaduvanshipip install image
来解决了问题。 - Rafael Ruiz Muñozimage
不是 PIL(与问题中提到的),它是另一个模块。参考资料:https://github.com/francescortiz/image。我有什么遗漏了吗? - Eric O. Lebigotpip
安装情况。使用pip -V
命令可以告诉您安装位置。在Unix系统下,可以使用which python
命令告诉您python
命令的位置。这两者应该很好地匹配。或者更好的方法是,使用python -c 'import sys; print sys.path'
命令可以告诉您python
命令查找模块的位置(对于Python 3,请使用print(sys.path)
)。 - Eric O. Lebigot另外提一下,我强烈推荐使用Pillow,它与 PIL 兼容且维护更好,能够在更新的系统上运行。
安装完毕后,你可以进行以下操作:
import PIL
或者from PIL import Image
etc..
首先安装Pillow,使用以下命令:
pip install Pillow
或者如下所示
c:\Python35>python -m pip install Pillow
然后在 Python 代码中,你可以调用:
from PIL import Image
“Pillow是Python Imaging Library(PIL)的一个分支,由于PIL不再维护,因此使用旧的模块名称以保持向后兼容性。” 来自pillow安装完成,但“no module named pillow” - python2.7 - Windows 7 - python -m install pillow
pip uninstall PIL
并且
pip install PIL
python
时使用的是Python 2而不是Python3(您可以使用python -V
检查此问题)。 - fourkpython -m pip install image
或者在Windows中运行命令提示符,然后导航到脚本文件夹
cd C:\Python27\Scripts
然后执行下面的命令
pip install image
python3 -m pip install Pillow
- Judder在Windows 10上,我通过以下方式成功到达:
cd "C:\Users\<your username>\AppData\Local\Programs\Python\Python37-32"
python -m pip install --upgrade pip <-- upgrading from 10.something to 19.2.2.
pip3 uninstall pillow
pip3 uninstall PIL
pip3 install image
在此之后,使用Python(例如,我的版本是Python 3.7)可以正常运行此程序...
import PIL
from PIL import image
我使用了:
pip install Pillow
我在Lib\site-packages中使用pip安装了PIL。当我将PIL移动到Lib目录下时,一切都正常工作。我使用的是Windows 10。
安装特定版本:
pip install Pillow
升级 Pillow
sudo pip3 install --upgrade Pillow
在Windows 10中遇到依赖错误 使用代码:easy_install而不是pip install
easy_install Pillow
使用易安装进行升级
sudo easy_install --upgrade Pillow
在OSX系统上安装模块: 使用代码:brew install 而不是pip install
brew install Pillow
不使用Pip :
sudo apt-get install -y Pillow
在CentOS7或Linux Fedora上:
yum -y install Pillow
或者在 Fedora 上尝试
sudo dnf install Pillow
如果Homebrew在macOS上搞砸了你的路径,请使用以下命令:
python -m pip install Pillow
针对Python3 MacOs Homebrew安装问题
python3 -m pip install Pillow
从列表中验证MacOS模块
pip freeze | grep Pillow
使用Anaconda作为您的Python包管理器进行执行
conda install -c anaconda Pillow
from PIL import Image
,但这种方法不起作用。 - Janne Karilaeasy_install Pillow
。Pillow是PIL的一个分支,具有更好的打包和支持Python 3的功能。 - Lennart Regebropip install Pillow
命令进行安装。然后您就可以使用import PIL.Image
进行导入。 - Tiago Martins Peres