出现这个问题的主要原因是,jupyter的内核(或者说他使用的Python环境)与下载库的环境不一样,解决办法就是更改kernel。换句话说就是将jupyter下载库的环境加入到内核环境中。
1.命令行输入jupyter kernelspec list,可以查看现在jupyter拥有的python环境

2.conda env list,查看目前jupyter使用的下载库的环境

如果你的这个环境不在1的kernelspec list中,那么就可以跟着往下做。
activate base,激活虚拟环境pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn.com/simple,安装ipykernelipython kernel install --name base 出现问题-验证2中的conda环境映射名 e.g.我的为base。jupyter-kernelspec list #查看jupyter注册的所有kernel,查看是否有base的kernelconda deactivatejupyter-kernelspec uninstall 4.重启jupyter,打开jupyter notebook更换环境

如果在jupter中下载新的库
1.简单点
!pip install module_name
2.嫌慢,加上源头
!pip install moudle_name -i 国内常用镜像源
e.g. !pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple
清华大学: https://pypi.tuna.tsinghua.edu.cn/simple
阿里云: https://mirrors.aliyun.com/pypi/simple
豆瓣: http://pypi.douban.com/simple
中国科学技术大学: http://pypi.mirrors.ustc.edu.cn/simple
华中理工大学:http://pypi.hustunique.com/simple
山东理工大学:http://pypi.sdutlinux.org/simple