pillow - 属性错误 : 'module' object has no attribute 'Number'

标签 pillow

不知道是什么原因造成的...

我正在使用“Pillow-3.3.0.win32-py34.exe”安装文件运行 Python 3.4.3。

在导入图像时

from PIL import Image

我尝试使用将“a.jpg”设置为我的图像
img = Image.open("a.jpg")

但是我得到这个错误,
>>> img = Image.open("a.jpg")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\PIL\Image.py", line 2289, in open
    preinit()
  File "C:\Python34\lib\site-packages\PIL\Image.py", line 365, in preinit
    from PIL import JpegImagePlugin
  File "C:\Python34\lib\site-packages\PIL\JpegImagePlugin.py", line 40, in <modu
le>
    from PIL import Image, ImageFile, TiffImagePlugin, _binary
  File "C:\Python34\lib\site-packages\PIL\TiffImagePlugin.py", line 50, in <modu
le>
    from fractions import Fraction
  File "C:\Python34\lib\fractions.py", line 6, in <module>
    from decimal import Decimal
  File "C:\Python34\lib\decimal.py", line 3855, in <module>
    _numbers.Number.register(Decimal)
AttributeError: 'module' object has no attribute 'Number'

可能与 Pillow 无关,但仍然非常感谢帮助!

最佳答案

是否有一个名为 numbers.py 的文件?在当前工作目录中?

这可能是问题的原因,因为它会阻止标准库模块的导入 numbers .

(来自 here 的建议。)

关于pillow - 属性错误 : 'module' object has no attribute 'Number' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38703637/

相关文章:

python - 编码 Base64 Django ImageField 流

jpeg - JPEG在DICOM中无损

python - 从列表中制作图像

python - 用 Pillow 像素化图像

python - 使用 PIL 修改然后保存 TIFF 返回错误

python - .dilate()OpenCV的替代方法

python-3.6 - 无法将 RGBA 模式写为 JPEG

python - ValueError : jpeg is required unless explicitly disabled using --disable-jpeg, 中止

python - 如何在 Spyder(Anaconda 3) 上安装 PIL?