PackagesNotFoundError and Conda Install

If you are installing package with conda and you are encountering an issue.

PackagesNotFoundError: The following packages are not available from current channels:

- c-compiler
- fortran-compiler
- cxx-compiler

There is a workaround below. IThis is important as it tells conda to also look on the conda-forge channel when you search for packages.

conda config --append channels conda-forge
## Package Plan ##

  environment location: /usr/local/anaconda3-2022/envs/sagemath_env

  added / updated specs:
    - c-compiler
    - cxx-compiler
    - fortran-compiler
    - pkg-config

The following packages will be downloaded:

    package                    |            build
    _libgcc_mutex-0.1          |             main           3 KB
    _openmp_mutex-5.1          |            1_gnu          21 KB
    binutils-2.36.1            |       hdd6e379_2          27 KB  conda-forge
    binutils_impl_linux-64-2.36.1|       h193b22a_2        10.4 MB  conda-forge
    binutils_linux-64-2.36     |      hf3e587d_10          24 KB  conda-forge
    c-compiler-1.5.0           |       h166bdaf_0           5 KB  conda-forge
    cxx-compiler-1.5.0         |       h924138e_0           5 KB  conda-forge
    fortran-compiler-1.5.0     |       h2a4ca65_0           5 KB  conda-forge
    gcc-10.4.0                 |      hb92f740_10          24 KB  conda-forge
    gcc_impl_linux-64-10.4.0   |      h7ee1905_16        46.7 MB  conda-forge
    gcc_linux-64-10.4.0        |      h9215b83_10          25 KB  conda-forge
    gfortran-10.4.0            |      h0c96582_10          24 KB  conda-forge

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