使用系统:ubuntu18.04
故事起源于在jupyter notebook 里面导入torch库时报错:
原因:当前虚拟环境中无torch这个库
解决方案:切换到一个已经安装完pytorch库的虚拟环境。
搜索:“anaconda切换虚拟环境”
参考:
Anaconda查看、创建、切换虚拟环境_AIHUBEI的博客-CSDN博客_anaconda切换虚拟环境
在终端输入语句:
①conda env list
(为了查看当前已创建的环境)
②conda activate XXXXX
(XXXXX为除base外的另一个虚拟环境,不同人的不一样。)
结果输入语句②切换虚拟环境时报错:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
搜索:“CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME>”
参考: