当前位置:   article > 正文

Unbuntu中使用conda activate报错_ubuntu conda activate不能用

ubuntu conda activate不能用


)

解决Unbuntu中使用conda activate报错:CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’

安装Anaconda之后需要配置环境变量:

使用:
vim ~/.bashrc
输入:
export PATH=~/anaconda3/bin:$PATH
退出后执行:
source ~/.bashrc
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

此时在终端中输入python

xxx@xxx-ThinkCentre-M730e-N010:~$ python
Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
  • 1
  • 2
  • 3
  • 4
  • 5

如果输出中有Anaconda则表明环境配置成功

但是如果此时输入conda activate则报错如下

xxx@xxx-ThinkCentre-M730e-N010:~$ conda activate

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'.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

原因是没有启动conda.sh,该文件在~/anaconda3/etc/profile.d/conda.sh目录下

解决办法有两个

方法1:
source activate
然后就可以执行
conda activate xxx_env
  • 1
  • 2
  • 3
  • 4
方法2:
使用:
vim ~/.bashrc
输入:
export PATH=~/anaconda3/bin:$PATH
source ~/anaconda3/etc/profile.d/conda.sh
退出后执行:
source ~/.bashrc

然后就可以执行
conda activate
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/924586
推荐阅读
相关标签
  

闽ICP备14008679号