python pil模块导入失败,ImportError:无法导入在tensorflow上加载图像文件所需的Python Imaging Library(PIL)...

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

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

Error Image

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

Operating System:

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

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

0.11.0

解决方案

pip install pillow

Then replace

from IPython.display import display, Image

with

from IPython.display import display

from PIL import Image

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值