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 (环境名称)"
jupyter notebook中import tensorflow 错误,socket.gaierror: [Errno -5] No address associated with host..._第1张图片
在Change kerne中就可以看到你(环境名称)的kernel了,选中就对了
jupyter notebook中import tensorflow 错误,socket.gaierror: [Errno -5] No address associated with host..._第2张图片
image.png

你可能感兴趣的:(jupyter notebook中import tensorflow 错误,socket.gaierror: [Errno -5] No address associated with host...)