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!

1 Like

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.

Hi!

I am not sure how you found that solution. I have the same problem but running that didn’t fix it in my case. Could you help me with it? Thank you.

@dexterhu Thank you. your solution(After I install, I cannot activate the enviroment and I fixed it, but what was wrong?) help me :laughing:

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

solution
Worked after a
conda init zsh

Hello!

I’m not entirely sure about the reason you mentioned. If the ‘<path_to_anaconda>/anaconda3’ was not included in the .bashrc file, the ‘echo $PATH’ command would not display the correct anaconda3 path (but, as I mentioned, it actually displayed the anaconda3 path correctly).

Hi,

Sorry for the delay in getting back. Have you given sweller’s solution which involves adding the directory ‘<path_to_anaconda>/anaconda3’ to the .bashrc file? If the issue persists, can you provide more detailed information such as the OS or Anaconda version?