[Conda] Error: CondaValueError — Key 'channels' is not a list — How to Fix It

Summary

The CondaValueError: Key 'channels' is not a list error means Conda cannot parse your configuration file (.condarc) because the channels key is incorrectly formatted. Conda expects this key to be a YAML list, but the file defines it as a single string or with invalid indentation. Correcting the syntax or recreating the configuration file resolves the issue immediately.

Context

Conda uses a YAML-based configuration file called .condarc to define settings like channels, proxies, and environment paths. YAML requires lists to be expressed with dashes under a key (e.g., channels: followed by indented entries). When channels is written as a string (e.g., channels: defaults) or formatted incorrectly, Conda throws a parsing error and stops reading configuration values. This usually happens after manual edits or copying configurations between systems.

Probable Cause

  • Improper YAML syntax in the .condarc file.
  • channels defined as a single string instead of a YAML list.
  • Indentation or whitespace issues causing YAML parsing to fail.
  • Corrupted or partially written configuration file after a failed edit.

Quick Fix

Repair the configuration format step by step:

  1. Locate your .condarc file:
# Windows
%USERPROFILE%\.condarc

# Linux/macOS
~/.condarc
  1. Open the file and check the channels section.
  2. ❌ Wrong format (causes the error):
channels: defaults
  1. ✅ Correct format (YAML list syntax):
channels:
  - defaults
  - conda-forge
  1. Save the file and close it.
  2. Test Conda’s configuration parsing:
conda config --show channels
  1. If the channels are displayed correctly, the issue is resolved.
  2. If the file seems corrupted, recreate it from scratch:
# Windows
del %USERPROFILE%\.condarc

# Linux/macOS
rm ~/.condarc
  1. Then rebuild it cleanly:
conda config --add channels conda-forge

Full Example

A user edits .condarc manually and writes:

channels: defaults

Running any Conda command returns:

CondaValueError: Key 'channels' is not a list, value: defaults

They open the file and correct it to:

channels:
  - defaults
  - conda-forge

After saving, conda config --show channels correctly outputs:

channels:
  - defaults
  - conda-forge

The error disappears, and Conda loads configuration normally.

Pitfalls & Debug

  • Symptom: Error persists even after fixing syntax → Fix: Delete and recreate .condarc entirely.
  • Symptom: “could not parse YAML” → Fix: Remove stray spaces or invisible tabs.
  • Symptom: Conda ignores channels → Fix: Confirm indentation uses two spaces, not tabs.
  • Symptom: Using wrong path → Fix: Verify you’re editing the correct user’s .condarc.
  • Symptom: Same issue after sync → Fix: Ensure file encoding is UTF-8 without BOM.

Validation & Next Steps

Run:

conda config --show channels

If it displays a list of channels, your configuration is valid. As a preventive step, avoid manual edits unless familiar with YAML syntax, and use conda config commands to manage settings safely.

Sources

Anaconda Documentation — Managing .condarc
Stack Overflow — “CondaValueError: Key 'channels' is not a list” discussions
conda-forge Wiki — YAML syntax examples and config tips
Anaconda Community Forum — Configuration troubleshooting threads

Labels: Tool/Conda, OS/Windows-macOS-Linux, Topic/Configuration-YAML