title: How to install tensorflow in raspberry pi with python 3.5.3
body: <p><strong>Summery</strong></p>
  
  <p>When I use <code>Sudo pip3 install --user --upgrade tensorflow</code>, I get</p>
  
  <blockquote>
    <p>TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'</p>
  </blockquote>
  
  <p>When I use <code>pip3 install --user --upgrade tensorflow</code>, I get </p>
  
  <blockquote>
    <p>MemoryError</p>
  </blockquote>
  
  <p>When I use  <code>sudo pip3 install tensorflow --no-cache-dir</code>, it is installing but cannot use in python.</p>
  
  <p>When I use <code>pip3 install tensorflow --no-cache-dir</code>, I get </p>
  
  <blockquote>
    <p>TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'</p>
  </blockquote>
  
  <hr>
  
  <p>I am using Raspbian Stretch with desktop and recommended software new version which is released in 2018-11-13. I am using raspberry pi 2 modal B.</p>
  
  <p>I tried to install tensorflow according to recommended google guide. <a href="https://www.tensorflow.org/install/pip" rel="nofollow noreferrer">LINK</a></p>
  
  <p>Result of envirement.
  <a href="https://i.stack.imgur.com/6iuVJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6iuVJ.png" alt="result"></a></p>
  
  <p>When I give command <code>pip3 install --user --upgrade tensorflow</code> I got this error at 99 completeded of download.</p>
  
  <pre><code>Exception:
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
      status = self.run(options, args)
    File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
      wb.build(autobuilding=True)
    File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
      self.requirement_set.prepare_files(self.finder)
    File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
      ignore_dependencies=self.ignore_dependencies))
    File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
      session=self.session, hashes=hashes)
    File "/usr/lib/python3/dist-packages/pip/download.py", line 821, in unpack_url
      hashes=hashes
    File "/usr/lib/python3/dist-packages/pip/download.py", line 659, in unpack_http_url
      hashes)
    File "/usr/lib/python3/dist-packages/pip/download.py", line 882, in _download_http_url
      _download_url(resp, link, content_file, hashes)
    File "/usr/lib/python3/dist-packages/pip/download.py", line 603, in _download_url
      hashes.check_against_chunks(downloaded_chunks)
    File "/usr/lib/python3/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
      for chunk in chunks:
    File "/usr/lib/python3/dist-packages/pip/download.py", line 571, in written_chunks
      for chunk in chunks:
    File "/usr/lib/python3/dist-packages/pip/utils/ui.py", line 139, in iter
      for x in it:
    File "/usr/lib/python3/dist-packages/pip/download.py", line 560, in resp_read
      decode_content=False):
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py", line 432, in stream
      data = self.read(amt=amt, decode_content=decode_content)
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py", line 380, in read
      data = self._fp.read(amt)
    File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 63, in read
      self._close()
    File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 50, in _close
      self.__callback(self.__buf.getvalue())
    File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py", line 275, in cache_response
      self.serializer.dumps(request, response, body=body),
    File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 55, in dumps
      "body": _b64_encode_bytes(body),
    File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 12, in _b64_encode_bytes
      return base64.b64encode(b).decode("ascii")
    File "/usr/lib/python3.5/base64.py", line 59, in b64encode
      encoded = binascii.b2a_base64(s)[:-1]
  MemoryError
  </code></pre>
  
  <p>After that, I tried <code>pip3 install --no-cache-dir tensorflow</code> code but I got following error after finish the download. </p>
  
  <pre><code>Exception:
  Traceback (most recent call last):
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen
      chunked=chunked)
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 391, in _make_request
      six.raise_from(e, None)
    File "&lt;string&gt;", line 2, in raise_from
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 387, in _make_request
      httplib_response = conn.getresponse()
    File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
      response.begin()
    File "/usr/lib/python3.5/http/client.py", line 297, in begin
      version, status, reason = self._read_status()
    File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
      line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    File "/usr/lib/python3.5/socket.py", line 576, in readinto
      return self._sock.recv_into(b)
    File "/usr/lib/python3.5/ssl.py", line 937, in recv_into
      return self.read(nbytes, buffer)
    File "/usr/lib/python3.5/ssl.py", line 799, in read
      return self._sslobj.read(len, buffer)
    File "/usr/lib/python3.5/ssl.py", line 583, in read
      v = self._sslobj.read(len, buffer)
  ConnectionResetError: [Errno 104] Connection reset by peer
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
      status = self.run(options, args)
    File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 342, in run
      requirement_set.prepare_files(finder)
    File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
      ignore_dependencies=self.ignore_dependencies))
    File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
      require_hashes
    File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
      self.link = finder.find_requirement(self, upgrade)
    File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
      all_candidates = self.find_all_candidates(req.name)
    File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
      for page in self._get_pages(url_locations, project_name):
    File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
      page = self._get_page(location)
    File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
      return HTMLPage.get_page(link, session=self.session)
    File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
      "Cache-Control": "max-age=600",
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
      return self.request('GET', url, **kwargs)
    File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
      return super(PipSession, self).request(method, url, *args, **kwargs)
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
      resp = self.send(prep, **send_kwargs)
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 630, in send
      history = [resp for resp in gen] if allow_redirects else []
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 630, in &lt;listcomp&gt;
      history = [resp for resp in gen] if allow_redirects else []
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 190, in resolve_redirects
      **adapter_kwargs
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
      r = adapter.send(request, **kwargs)
    File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
      timeout=timeout
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
      total -= 1
  TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
  </code></pre>
  
  <p>How to solve this error?</p>
  
  <p>Update:</p>
  
  <p>When I run <code>sudo pip3 install tensorflow --upgrade --no-cache-dir</code>, it say following detail but I can not import tensor library to my project. </p>
  
  <pre><code>pi@raspberrypi:~ $ sudo pip3 install tensorflow --upgrade --no-cache-dir
  Requirement already up-to-date: tensorflow in /usr/local/lib/python3.5/dist-packages
  Requirement already up-to-date: tensorboard&lt;1.12.0,&gt;=1.11.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: astor&gt;=0.6.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: setuptools&lt;=39.1.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: numpy&gt;=1.13.3 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: keras-preprocessing&gt;=1.0.3 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: wheel&gt;=0.26 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: protobuf&gt;=3.6.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: keras-applications&gt;=1.0.5 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: grpcio&gt;=1.8.6 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: absl-py&gt;=0.1.6 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: termcolor&gt;=1.1.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: gast&gt;=0.2.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: six&gt;=1.10.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow)
  Requirement already up-to-date: markdown&gt;=2.6.8 in /usr/local/lib/python3.5/dist-packages (from tensorboard&lt;1.12.0,&gt;=1.11.0-&gt;tensorflow)
  Requirement already up-to-date: werkzeug&gt;=0.11.10 in /usr/local/lib/python3.5/dist-packages (from tensorboard&lt;1.12.0,&gt;=1.11.0-&gt;tensorflow)
  Requirement already up-to-date: h5py in /usr/local/lib/python3.5/dist-packages (from keras-applications&gt;=1.0.5-&gt;tensorflow)
  </code></pre>
  
  <p>When I import the tensorflow I get following error massage.</p>
  
  <pre><code>/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
    return f(*args, **kwds)
  /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
    return f(*args, **kwds)
  </code></pre>