本文介绍了导入错误:无法导入在 tensorflow 上加载图像文件所需的 Python 成像库 (PIL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习关于 udacity 的深度学习课程.对于第一个任务,当我尝试运行问题 1 下方的脚本时,出现此错误.所以我尝试卸载 PIL 和枕头,然后单独安装它们,但我没有成功.我需要帮助的家伙.我在 python notebook 中使用 tensorflow docker 图像.

I am doing a deep learning course on udacity. For the first assignment whenI tried to run the script which is below the problem 1 , I got this error. So I tried to uninstall PIL and pillow and then installed these individually but I didnot succeeded.I need help guy. I am using tensorflow docker image with python notebook.

# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import scipy
import tarfile
from IPython.display import display, Image
from scipy import ndimage
from sklearn.linear_model import LogisticRegression
from six.moves.urllib.request import urlretrieve
from six.moves import cPickle as pickle
# Config the matplotlib backend as plotting inline in IPython
%matplotlib inline

url = 'http://commondatastorage.googleapis.com/books1000/'
last_percent_reported = None

def download_progress_hook(count, blockSize, totalSize):
    percent = int(count * blockSize * 100 / totalSize)

   if last_percent_reported != percent:
     if percent % 5 == 0:
  sys.stdout.write("%s%%" % percent)
  sys.stdout.flush()
else:
  sys.stdout.write(".")
  sys.stdout.flush()

last_percent_reported = percent

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/1_notmnist.ipynb

您可以在此处查看代码.我在问题 1 之后的代码块中出错错误图片

You can see the code here. I got error in the code block after problem 1Error Image

我尝试了这两个链接或解决方案中描述的所有内容:

I tried each and everything describe here in these two links or solutions:

stackoverflow 上的解决方案 1

stackoverflow 上的解决方案 2

操作系统:

使用 docker 和 tensorflow 安装在带有 IPython notebook 的容器中.

using docker and tensorflow is installed in a container with IPython notebook.

python -c "import tensorflow; print(tensorflow.version)" 的输出.

The output from python -c "import tensorflow; print(tensorflow.version)".

0.11.0

推荐答案

pip installpil

然后替换from IPython.display 导入显示,图片from IPython.display 导入显示从 PIL 导入图片

这篇关于导入错误:无法导入在 tensorflow 上加载图像文件所需的 Python 成像库 (PIL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:35