BlaXuan 发表于 2022-6-24 08:15

使用Anaconda安装tensorflow,keras(Windows)

主要记载一下在windows上安装tensorflow遇到的问题及安装步骤。不要在原来的环境上安装,因为会重新安装一套库如numpy等,会导致下载多个版本。
1. Anaconda安装tensorflow。

使用Anaconda创建虚拟环境非常方便,这里安装Anaconda的方法可以参考Windows下Anaconda的下载,安装与使用。
在Anaconda Prompt中输入命令,创建conda环境


conda create -n tensorflow python=3.6稍等,创建完环境后,激活环境。
activate tensorflow安装tensorflow
pip install tensorflow在使用pip install tensorflow安装tensorflow时,报错:



WARNING:Retrying(Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001B40D0D4948>:Failedtoestablish a new connection: 向一个无法连接的网络尝试了一个套接字操作。')':/simple/tensorflow/网上搜索一堆方法用来安装tensoflow:
常规安装:
pip install --upgrade --ignore-installed tensorflow使用镜像:
阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/但是经过网上给的方法进行安装,还是出现错误。
最终的解决办法:
pip install tensorflow -i http://pypi.douban.com/simple --trusted-host pypi.douban.comtensorflow可以更换为你想下载的库,之后只需要等待即可。
2. 安装 keras 库

keras搭建在tensorflow基础上,在安装keras安装之前需要安装tensorflow、numpy、matplotlib、scipy。
pip install numpy
pip install matplotlib
pip install scipy
pip install tensorflow
pip install keras3. 同时安装

如果需要直接安装对应版本的tensorflow库和keras库:
pip install -i https://pypi.douban.com/simple tensorflow==1.14 keras==2.1
<div id="marketingBox" class="marketing-box"><div class="marketing-content">


CSDN 社区图书馆,开张营业!


深读计划,写书评领图书福利~
页: [1]
查看完整版本: 使用Anaconda安装tensorflow,keras(Windows)