使用tensorflow时没有名为'Pil'的模块

时间:2017-10-23 06:40:33

标签: python tensorflow pip anaconda

我对机器学习完全陌生。我正在使用Tensorflow进行机器学习。虽然,我正在关注code lab。我正在压缩我的模型并使用以下脚本进行测试

python -m scripts.evaluate  tf_files/optimized_graph.pb

我得到了这个例外no module name 'Pil' 下面是截图。

enter image description here

当我尝试使用此命令pip install Pillow安装pip时。我得到了这个例外。

例外:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\ba
and.py", line 215, in main
    status = self.run(options, args)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\co
\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\wh
", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\re
set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\re
set.py", line 554, in _prepare_file
    require_hashes
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\re
install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\pip\in
", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

我是新手,不知道出了什么问题

已更新

正如Bodhi94在回答中所建议的那样我用链接中给出的git文件替换了我的html5并成功安装pip install Pillow但是当我再次运行python -m scripts.evaluate tf_files/optimized_graph.pb命令时它给了我这个例外。

  File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\runpy.py", line 193, 
in _run_module_as_main
"__main__", mod_spec)
 File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\runpy.py", line 85, in 
_run_code   exec(code, run_globals)
 File "D:\tensorflow\tensorflow-for-poets-2\scripts\evaluate.py", line 91, in <module>
accuracy,xent = evaluate_graph(*sys.argv[1:])
 File "D:\tensorflow\tensorflow-for-poets-2\scripts\evaluate.py", line 37, in evaluate_graph
 image_buffer_input = graph.get_tensor_by_name('input:0')
 File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 2880, in get_tensor_by_name
 return self.as_graph_element(name, allow_tensor=True, allow_operation=False)

 File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 2708, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "C:\ProgramData\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 2750, in _as_graph_element_locked
"graph." % (repr(name), repr(op_name)))
KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."

1 个答案:

答案 0 :(得分:3)

尝试使用以下命令安装 html5lib

conda install --force html5lib

他们尝试使用

安装枕头
pip install Pillow