Linux下Conda装旧版Matplotlib遇KeyError及PrimerProspector安装求助
Let’s work through this problem step by step—you’re running Ubuntu Server 16.04.3 LTS with Conda 4.4.8, set up a Python 2.6 environment to handle PrimerProspector’s development version dependencies, added the conda-forge channel, but keep hitting a KeyError when trying to install an older Matplotlib. Here’s how to resolve this:
1. Clear Conda Cache & Fix Channel Priorities
The KeyError usually comes from corrupted package indexes or misordered channels. Let’s reset that first:
- Wipe all cached packages and stale index data to eliminate outdated references:
conda clean --all -y - Configure channels to prioritize conda-forge (it maintains more legacy packages for old Python versions than the default channel), and enforce strict priority:
Note: Python 2.6 is end-of-life, so conda-forge’s support is limited to older build sets. Add theconda config --add channels conda-forge conda config --add channels defaults conda config --set channel_priority strictcf201901label (the last conda-forge release line supporting Python 2.6) to access compatible packages:conda config --add channels conda-forge/label/cf201901
2. Install a Matplotlib Version Compatible with Python 2.6
The final Matplotlib version that supports Python 2.6 is 1.5.3. Install it explicitly to avoid version mismatches:
- First try via Conda (once your channels are fixed):
conda install matplotlib=1.5.3 -y - If you still get a KeyError, switch to pip—Conda’s index may no longer host the exact build for your system/Python combination:
pip install matplotlib==1.5.3
3. Lock in Compatible PyCogent & Numpy Versions
Python 2.6 requires specific dependency versions to work correctly:
- For Numpy: Install the last version supporting Python 2.6 (1.11.3):
conda install numpy=1.11.3 -y - For PyCogent: Use version 1.9 (the final release that supports Python 2.6):
pip install pycogent==1.9
4. Upgrade Conda to a Python 2.6-Supported Version
Your current Conda 4.4.8 is outdated and may have bugs handling legacy Python 2.6 environments. Upgrade to the last Conda version that supports Python 2.6 (4.6.14):
conda install conda=4.6.14 -y
This will improve compatibility with older package indexes and reduce unexpected errors like KeyError.
Why This Works
The KeyError happens when Conda can’t find a package build that matches your Python version, OS, and architecture. By cleaning the cache, prioritizing legacy-friendly channels, and explicitly specifying versions known to support Python 2.6, you eliminate the mismatches causing the error. Falling back to pip is a reliable backup when Conda’s index no longer hosts the required builds.
内容的提问来源于stack exchange,提问作者FM Kerckhof

