FaisalAhmed
FaisalAhmed

Reputation: 3651

no module named 'Pil' while using tensorflow

I am totally new to Machine learning. I was using Tensorflow for machine learning. While, i was following code lab for this. And i was compressing my model and testing it using following script

python -m scripts.evaluate  tf_files/optimized_graph.pb

i got this exception no module name 'Pil' below is screenshot.

enter image description here

when i tried installing pip using this command pip install Pillow. I got this exception.

Exception:

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'

I am new to this and don't know whats going wrong

UPDATED

as suggested from Bodhi94 in answer bellow i replaced my html5 with the git file given in link and successfully installed pip install Pillow but when i run python -m scripts.evaluate tf_files/optimized_graph.pb command again it gave me this exception.

  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."

Upvotes: 1

Views: 1547

Answers (1)

Vibhutha Kumarage
Vibhutha Kumarage

Reputation: 1399

Try to install html5lib library using the following command

conda install --force html5lib

They try to install pillow using

pip install Pillow

Upvotes: 3

Related Questions