jupyter notebook中import tensorflow 错误,socket.gaierror: [Errno -5] No address associated with host...

jupyter notebook中import tensorflow 错误,出现错误的原因是,我们在安装anaconda时,jupyter已经默认安装了,安装所在的环境是默认环境,当我们新建了新的环境时,jupyter使用的环境还是在原来的默认环境中,所以,我们需要在新的环境中重新安装jupyter notebook

conda install ipython
conda install jupyter

然后记得配置新的环境https://www.jianshu.com/p/00070910dad0,但是,可能会出现
KeyError: 'allow_remote_access'
ValueError: '' does not appear to be an IPv4 or IPv6 address
socket.gaierror: [Errno -5] No address associated with hostname

然后对config文件做了修改如下

c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.password = u'sha1:e91d9d25ad12:2938334445359d3771dba613678dc3dc4afb3'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8822
c.NotebookApp.allow_remote_access = '*'

修改位置为
c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.allow_remote_access = '*'

然后接下来,我们要是jupyter适用不同的conda环境

conda install ipykernel  

激活我们需要的conda环境

source activate 环境名称

将环境写入notebook的kernel中

python -m ipykernel install --user --name 环境名称 --display-name "Python (环境名称)"
在Change kerne中就可以看到你(环境名称)的kernel了,选中就对了
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容