Win10+VScode +miniconda安装tensorflow(CPU版本)

一、安装tensorflow

1.安装

conda activate py36
conda install tensorflow  //安装

2.若安装提示下面的错误。

 解决方案:打开Anaconda Prompt(miniconda3),输入以下命令

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

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/pkgs/free/

conda config --set show_channel_urls yes

然后,激活py36再次安装tensorflow

conda activate py36
conda install tensorflow

3.安装完成后,新增环境变量

查看tensorflow是否安装成功,在py36虚拟环境中输入:

pip show tensorflow

4.配置vscode中的settings.json文件(python->扩展设置->extra paths->在settings.json中编辑) ,如下所示,然后重新启动vscode。

"python.pythonPath": "D:\\APP\\Miniconda3\\envs\\py36\\python.exe",
    "python.autoComplete.extraPaths": [                
        "D:\\APP\\Miniconda3\\envs\\py36",            
        "D:\\APP\\Miniconda3\\envs\\py36\\lib\\site-packages"        
    ],        
    "python.autoComplete.addBrackets":true,

5.新建py文件,直接运行。

 如果报下面的错误,大概就是找不到numpy,DLL load failed: 找不到指定的模块。

 解决方法:用pip重新安装numpy(若numpy下载过程出现错误,是网速问题)

注意:tensorflow版本和numpy版本要适配!!!我的是tensorflow1.2.0+numpy1.14.0

pip uninstall numpy //卸载numpy
pip3 install numpy==1.14.0 //用pip重新安装numpy

6.若出现VCcode终端不能正确激活miniconda的环境的问题,打开步骤4中的setting.json文件,增加如下的代码

"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/K",
        "D:\\APP\\Miniconda3\\Scripts\\activate.bat D:\\APP\\Miniconda3"],   //此处是miniconda3所在的位置

打开vscode终端效果如下:

 7.运行py文件

python 1.py  //1.py为文件名

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值