Anaconda及tensorflow2.3.0、pytorch1.6安装记录
视频过程请进:https://www.bilibili.com/video/BV1nK4y1e7Ke/
我的python版本3.5.2,有点旧了,跟不上时代,但是更新的话又得卸载再安装新的版本,这样一来我原来安装python的很多库就得重新安装了。
据说Anaconda这个软件能解决这个问题,并能很好在安装时的提供依赖,是安装顺利完成,索性把旧的python卸载了,装这个试试。
1、卸载python
方法,https://www.python.org/downloads/打开python官网下载你对应的旧版本(用于卸载):

下载到本地:

双击旧版本安装程序点击Uninstall卸载(如果下对了旧版本是会出现卸载提示的):



2、安装anaconda
打开www.anaconda.com





等下载完成:


双击打开程序开始安装:











出现了程序主界面,右侧是启动图标,launch为已安装的库,可以直接启动,install为没安装的库,按你需要安装即可:



1、清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
2、中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
3、重置回默认源
conda config --remove-key channels
接下来直接在这个环境安装你需要的库(比如我要装tensorflow):
打开win命令行,然后就是输入命令(网络好的话可以不加“-i 源地址”):
pip install tensorflow-gpu -i https://pypi.mirrors.ustc.edu.cn/simple/



运行一下tensorflow:

提示错误:ImportError: DLL load failed while inporting _pywrap_ tensorflow_ internal: 找不到指定的模块。
装一下必要的环境,到这个网址下载安装:https://aka.ms/vs/16/release/vc_redist.x64.exe

完成后重启电脑后再次运行tensorflow,成功!!真是激动人心,之前好久都没有装上。

装个pytorch:
打开https://pytorch.org/get-started/locally/
选好自己的需要:

pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.or
g/whl/torch_stable.html

如果安装完成,import torch 失败:
跟着上面安装tensorflow的一样,装过vc_redist.x64.exe了就没这个错误:

至此,可以看出安装完成anaconda后也是可以像原生安装python一样使用的。
升级python和conda版本
在Prompt窗口中输入执行就可以了:conda updata python
