Can’t execute `conda activate` from bash script

I am still new to Anaconda and I encountered this error

"Can't execute conda activate from bash script"

To resolve the issue was pretty fast. I took a look at

source ~/anaconda3/etc/profile.d/
conda activate my_env


Solving environment: failed with initial frozen solve. Retrying with flexible solve

When I was loading my anaconda-2020, I’ve received this error.

conda install -c conda-forge opencv

And I got this error

Solving environment: failed with initial frozen solve. Retrying with flexible solve....

There was this thread from github which was useful and it help a lot!

Step 1: To resolve, Create an environment called opencv using

conda create -n opencv

Step 2: Activate it

conda activate opencv

Step 3: Install it again

conda install -c anaconda opencv

(which install opencv 3, but not the most recent 4. In order to create a second environment called opencv4. Use above code to create and activate and do a standard download:

conda install -c conda-forge opencv

Installing conda packages locally in own directory

Step 1: Module load the anaconda module in HPC (if you are using Module Environment)

$ module load anaconda2019/python3

Step 2: Create a virtual environment locally and install packages

$ conda create -y -n my-own-conda-env

You can rename my-own-conda-env with any name. It is good practise to have a “-env” postfix.

Step 2(Option) : Install conda-env in non-default directory

If you wish to install in other directory instead of the default ~/.conda/envs, you have to use the “-p” parameters

$ conda create -y -p ~/my-conda-direct-env

Step 3: Activate the conda environment

$ source activate my-own-conda-env

You should see the environment activated which is prefix the login prompt.

(conda-env) [user1@hpc-n001 ~]$

Step 4: Download and install the conda package

$ conda install -c  ipyrad ipyrad

Step 5: Check for installed package

$ conda list

Step 6: Deactivate environment

$ source deactivate

The command prompt will be revert back without the conda environment

[user1@hpc-n001 ~]$

Conda versus pip virtualenv commands

I find this comparison very useful when trying to understand conda and pip. The information has been taken from Conda Command Conference


Task Conda package and environment manager command Pip package manager command
Install a package conda install $PACKAGE_NAME pip install $PACKAGE_NAME
Update a package conda update --name $ENVIRONMENT_NAME $PACKAGE_NAME pip install --upgrade $PACKAGE_NAME
Update package manager conda update conda Linux/macOS: pip install -U pip Win: python -m pip install -U pip
Uninstall a package conda remove --name $ENVIRONMENT_NAME $PACKAGE_NAME pip uninstall $PACKAGE_NAME
Create an environment conda create --name $ENVIRONMENT_NAME python X
Activate an environment conda activate $ENVIRONMENT_NAME* X
Deactivate an environment conda deactivate X
Search available packages conda search $SEARCH_TERM pip search $SEARCH_TERM
Install package from specific source conda install --channel $URL $PACKAGE_NAME pip install --index-url $URL $PACKAGE_NAME
List installed packages conda list --name $ENVIRONMENT_NAME pip list
Create requirements file conda list --export pip freeze
List all environments conda info --envs X
Install other package manager conda install pip pip install conda
Install Python conda install python=x.x X
Update Python conda update python* X


  1. Conda Command Conference

Understanding Conda and Pip

The information on understanding Conda and Pip by Anaconda is really good. The summary of the table is below

Comparison of conda and pip

conda pip
manages binaries wheel or source
can require compilers no yes
package types any Python-only
create environment yes, built-in no, requires virtualenv or venv
dependency checks yes no
package sources Anaconda repo and cloud PyPI