After I install, I cannot activate the enviroment and I fixed it, but what was wrong?

I just fixed the issue. My question is what was worng?

OS: CentOS 8.
Build: Anaconda3-2023.07-2-Linux-x86_64.sh
Problem: After I create an environment correctly, and when I activate that created envroment I got error message as below:

conda activate parth
usage: conda [-h] [--no-plugins] [-V] COMMAND ...
conda: error: argument COMMAND: invalid choice: 'activate' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'notices', 'package', 'remove', 'uninstall', 'rename', 'run', 'search', 'update', 'upgrade', 'build', 'convert', 'debug', 'develop', 'doctor', 'index', 'inspect', 'metapackage', 'render', 'skeleton', 'verify', 'content-trust', 'repo', 'env', 'token', 'server', 'pack')

More information: conda --version; conda create --name; conda env list. All worked well. echo $PATH shows anaconda3 path well. Just activate enviroment didn’t work.

Tried reinstall, intall different version. All didn’t fix the issue.

Fixed solution: after I ran this, I can activate enviroment

source {path_to_anaconda}/anaconda3/etc/profile.d/conda.sh

Question: what was wrong? what this command does
source {path_to_anaconda}/anaconda3/etc/profile.d/conda.sh
I’m a beginer please explain to me in details. Thanks a lot!

Hello,

I think the problem is that conda.sh is not part of your Linux PATH. After installing anaconda it will ask you if it should run ‘conda init’ to set up your environment. This will add the conda directory to your Linux PATH. Check your .bashrc file and make sure that the directory ‘<path_to_anaconda>/anaconda3’ is added to the .bashrc file then start a new shell and all should work as expected.