BayarBH
BayarBH

Reputation: 41

Error about Python when installing Tensorflow

Am have tried to download both tensorflow and tensorflow-gpu on Ubuntu16.04, it didn't work.. I was using pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu

It's ok at first, but after a while it was stuck. it appears ERROR like below:

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorflow-gpu
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ce/9a/6a3985daf15d0b87b1ef3c499293cf0889cd294223a6ca28b9529770b29e/tensorflow_gpu-2.0.0-cp27-cp27mu-manylinux2010_x86_64.whl (380.8MB)
     |▍                               | 4.8MB 8.0kB/s eta 13:03:00ERROR: Exception:
Traceback (most recent call last):
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 313, in _get_abstract_dist_for
    req, self.session, self.finder, self.require_hashes
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 194, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 465, in unpack_url
    progress_bar=progress_bar
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 316, in unpack_http_url
    progress_bar)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 551, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 253, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/utils/hashes.py", line 80, in check_against_chunks
    for chunk in chunks:
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 223, in written_chunks
    for chunk in chunks:
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/utils/ui.py", line 160, in iter
    for x in it:
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 212, in resp_read
    decode_content=False):
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 564, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 529, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/bayar/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 439, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out.

I have tried several times. I thought it were problem caused by pip, so I used pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu also. However, another problem came up.

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu
Collecting tensorflow-gpu
  Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )
No matching distribution found for tensorflow-gpu

Could you do me a favor?

Upvotes: 0

Views: 485

Answers (2)

Talha Junaid
Talha Junaid

Reputation: 2405

Check your python path using which python If this is equal to the python's expected path then use the following commands to install the packages.

python -m pip install tensorflow
python -m pip install tensorflow-gpu

Upvotes: 1

Kalana
Kalana

Reputation: 6143

To install tensorflow try this

pip3 install --upgrade tensorflow

To install tensorflow-gpu try this

pip3 install tensorflow-gpu

Upvotes: 2

Related Questions