在安装tensorflow时,不知道怎么了,一直安装不上去,所以重新配置了下镜像
安装环境:win10+anaconda3.5
- 删除之前的镜像源,恢复默认状态
conda config --remove-key channels
- 添加清华镜像源 清华大学开源软件镜像站
#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
#显示检索路径
conda config --set show_channel_urls yes
#显示镜像通道
conda config --show channels
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- 安装
conda install tensorflow
时仍然报错,解决方案如下:
- 打开.condarc文件,win10是在C:\Users\用户名文件夹中,用记事本打开即可,删除 -defaults,好像还是不行
- 接下来,将https全部改为http,经测试可以成功安装tensorflow
conda config --remove channels defaults
查看是否安装了gpu版本
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
- 国内常见的镜像源
pip install numpy -i https://mirrors.aliyun.com/pypi/simple/
国内常用源镜像地址:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
- 补充:conda的常用命令
- 查看所有虚拟环境
conda info --env
在显示的环境中,有*的表示当前所在的环境- 创建环境
conda create -n envname python=3.6
(指定python版本为3.6)- 启动环境
conda activate envnane
- 关闭环境
conda deactivate envname
- 删除环境
conda remove -n envname --all
- 克隆环境 本地已有一个环境AAA,若需要创建一个同样的BBB
conda create -n BBB --clone AAA
- linux安装tensorflow
anaconda search -t conda tensorflow
查看tensorflow版本,根据自己的系统环境,选择指定的版本anaconda show <NAME/PACKAGE>
显示版本的详细信息,并根据最后一句话进行安装