使用jupyter notebook导入tensorflow(2.1)之致命大坑

写这篇博客的目的是为了帮助想要使用jupyter notebook导入tensorflow的朋友避开一个大坑!

问题描述:我在安装anaconda3,以及tensorflow2.1成功后,想要使用jupyter notebook导入tensorflow,但是Import的时候就报错了!大概就是jupyter使用的kernel(内核)找不到tensorflow的包。

我对此的理解:
我刚开始打开的jupyter notebook的kernel(内核)指向的是anaconda base环境中的python.exe,但是我将tensorflow安装到了另一个环境中,这个环境使用的是另一个python.exe,因此jupyter notebook当然找不到tensorflow这个包!

答主环境:win10(64bit),Anaconda3,tensorflow2.1

我尝试过很多方法,即网上搜索到的,如:
添加jupyter内核(kernel),一顿操作后,导致在Anaconda Prompt中无法进入tensorflow环境,甚至无法打开anaconda navigater以及jupyter notebook(闪退)

-----------------------------------------------------------------------------------------------------OK我们现在进入解决问题环节!
在安装好 Anaconda 以及 tensorflow 的基础上(网上有很多优秀教程,照做就好),保证你可以正常打开 Anaconda Navigater!!!(这点很重要)
如果无法正常打开Anaconda Navigater,万能方法:重新安装

打开Anaconda Navigater

使用jupyter notebook导入tensorflow(2.1)之致命大坑_第1张图片

点击切换到安装了tensorflow的环境(我这里是把tensorflow2.1安装到了名为tensorflow的环境里)

使用jupyter notebook导入tensorflow(2.1)之致命大坑_第2张图片
一般来说,一个新的环境,是没有安装jupyter notebook的,这也就是本博客所要讲述的关键所在,也是为什么我在安装了tensorflow却无法通过jupyter notebook导入的根本原因!!

那么解决的办法很简单,点击jupyter notebook下面的’install’ ,在新环境下安装它!(因为我已经安装好了,所以显示’launch’,没有安装的话就是’install’,可以参考我画的两个圈)
使用jupyter notebook导入tensorflow(2.1)之致命大坑_第3张图片
安装好后,点击’launch’ ,打开的jupyter notebook就可以导入tensorflow了!
使用jupyter notebook导入tensorflow(2.1)之致命大坑_第4张图片
使用jupyter notebook导入tensorflow(2.1)之致命大坑_第5张图片

你可能感兴趣的:(使用jupyter notebook导入tensorflow(2.1)之致命大坑)