jupyter中不能用tensorflow

简单记一下

先进入虚拟环境(比如我的source activate tf)。

然后在该环境下安装jupyter和ipython

pip install jupyter

pip install ipython

查看安装的jupyter和ipython是否在当前环境下

(tf) xxx@xxx:~/Desktop/Tasks/tf$ which jupyter
/home/xxx/.conda/envs/tf/bin/jupyter
(tf) xxx@xxx:~/Desktop/Tasks/tf$ which ipython
/home/xxx/.conda/envs/tf/bin/ipython

如果显示在anaconda下,或者.local文件下,那么就是全局的ipython或者jupyter。可以先退出该环境,卸载ipython和jupyter,直到which ipython/jupyter不显示任何信息。在进入虚拟环境安装juptyer和ipython。我自己是试了几次卸载安装才弄对,然后退出环境又去全局安装jupyter和ipython。最后显示虚拟环境和全局是分开了的。

最后,还是在虚拟环境中操作,输入下面的命令就可以了

ipython kernelspec install-self --user

看到

[InstallNativeKernelSpec] Installed kernelspec python3 in /home/xxx/.local/share/jupyter/kernels/python3

就可以啦。

上图

原文地址:https://www.cnblogs.com/harbin-ho/p/13218724.html