python如何安装keras和tensorflow

一. 通过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

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值