树莓派Raspbian Jessie下pip3安装Python包提示版本不匹配故障求助
Hey there, let's work through this issue you're hitting. The root problem here is a combination of your older Raspbian Jessie system, end-of-life Python 3.6.4, and outdated pip that can't locate compatible package versions. Here's a step-by-step fix:
1. Upgrade pip to a version compatible with Python 3.6
Your default pip3 (from the source-installed Python 3.6.4) is likely too old to find modern-but-still-compatible package versions. Python 3.6 supports up to pip 21.3.1, so upgrade it first:
pip3 install --upgrade pip==21.3.1
2. Install critical system dependencies for compiling packages
Since you're installing both Python and these libraries from source, you need system-level build tools and libraries to avoid silent compilation failures that can look like "no matching version" errors:
sudo apt-get update sudo apt-get install build-essential libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk libatlas-base-dev gfortran
libjpeg-dev/zlib1g-dev: Required for Pillow's core image processing featureslibatlas-base-dev/gfortran: Speeds up numpy compilation and enables its numerical functionalitypython-tk/tcl/tk dev libs: Needed for matplotlib's interactive plotting tools
3. Install compatible package versions with a reliable PyPI mirror
Newer package versions have dropped support for Python 3.6 and Raspbian Jessie, so we'll specify the last compatible releases. Use a mirror to avoid connectivity issues with the default PyPI index:
Install numpy first (matplotlib depends on it)
pip3 install numpy==1.19.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
1.19.5 is the final numpy version that supports Python 3.6.
Install Pillow
pip3 install pillow==8.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
8.4.0 is the last Pillow release compatible with Python 3.6.
Install matplotlib
pip3 install matplotlib==3.3.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
3.3.4 is the final matplotlib version that works with Python 3.6 and Raspbian Jessie.
Quick note on why this works:
Raspbian Jessie is no longer supported, so default package repos and PyPI's default index may not serve pre-built wheels or compatible source distributions for your system/Python combo. Upgrading pip ensures it can locate older, still-compatible package versions, while installing system dependencies eliminates compilation errors that often get mislabeled as "no matching version" issues.
内容的提问来源于stack exchange,提问作者Rex Low

