当前位置:   article > 正文

python如何安装keras和tensorflow_python keras安装

python keras安装

一. 通过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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

二. 安装tensorflow

安装完之后,运行程序,

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

1.报错 No module named ‘tensorflow’

ModuleNotFoundError: No module named 'tensorflow'
  • 1
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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

在这里插入图片描述

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

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

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

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/181556
推荐阅读
相关标签
  

闽ICP备14008679号