一. 通过pip install kears 安装 keras

通过windows+R按键组合,进入cmd终端,按以下命令操作即可。

C:\Users\zgd>pip install keras
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000010B93ED30D0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/keras/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000010B93EC6E20>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/keras/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000010B93EC6BE0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/keras/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000010B93EC6BB0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/keras/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000010B93EC6A00>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/keras/
Collecting keras
  Downloading keras-2.9.0-py2.py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 1.1 MB/s
Installing collected packages: keras
Successfully installed keras-2.9.0

C:\Users\zgd>python --version
Python 3.8.5

二. 安装tensorflow

安装完之后,运行程序,

from keras.datasets import imdb
(train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)

1.报错 No module named ‘tensorflow’

ModuleNotFoundError: No module named 'tensorflow'
C:\Users\54867>pip install tensorflow
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001CE290EE100>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001CE290E4F10>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001CE290E4D30>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001CE290E4BE0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001CE290E48E0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

在这里插入图片描述

2.同样的操作,换个时间段操作,部分成功

在这里插入图片描述
只是末尾提示在这里插入图片描述
查看pip list
没有找到tensorflow,意味着安装失败。
在这里插入图片描述

3.重复步骤2,成功安装tensorflow

在这里插入图片描述
在这里插入图片描述
提示安装成功:
在这里插入图片描述

4. Ignore above cudart dlerror if you do not have a GPU set up on your machine

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐