Docker容器pip安装旧库求助:无法升级python-requests至最新版本
bibbox/app-galaksio Docker Image Let's work through this step by step to get your image running with modern dependencies. First, let's recap the core issue to align on what's breaking:
Background
You're dealing with two nearly identical Docker images:
fikipollo/galaksio: Works correctly, using Bioblend 0.10.0 (which includes a workaround for a bug in oldrequestsversions)bibbox/app-galaksio: Fails due to dependency conflicts, using Bioblend 0.11.0 (where that critical workaround was removed)
Both images install the same system packages via apt, including an outdated python-requests 2.4.3 that still has the bug Bioblend 0.10.0 worked around. Downgrading Bioblend fixes the problem, but you want both images to use modern dependencies—and you're stuck upgrading requests via pip.
Here are actionable solutions to try:
1. Force Pip to Upgrade requests (Override System Package)
The system-installed python-requests from apt is likely blocking pip from upgrading it. Add the --upgrade flag explicitly to tell pip to replace the existing version:
# Modified dependency installation RUN apt-get update \ && apt-get install --no-install-recommends -y wget libapache2-mod-wsgi python-flask python-requests unzip python-pip \ && apt-get clean \ && pip install --upgrade requests>=2.20.0 \ && pip install bioblend fpdf
I recommend pinning to >=2.20.0 because that's a version where the bug in question was fixed—you can adjust to the latest compatible version if needed.
2. Remove the System requests Package Entirely
If the system package is causing unresolvable conflicts, strip it out before installing via pip:
RUN apt-get update \ && apt-get install --no-install-recommends -y wget libapache2-mod-wsgi python-flask unzip python-pip \ && apt-get remove -y python-requests \ && apt-get clean \ && pip install requests bioblend fpdf
This ensures you're only using the pip-installed version of requests, eliminating cross-package conflicts entirely.
3. Diagnose Hidden Dependency Constraints
It's possible bioblend itself has an implicit constraint that's holding requests back. To investigate, run these commands inside a running instance of the problematic image:
# Check bioblend's declared dependencies pip show bioblend # Scan for dependency conflicts pip check # Generate a full dependency tree to spot issues pipdeptree
If you find Bioblend 0.11.0 actually requires an older requests version, you might need to either:
- Use a newer Bioblend version that supports modern
requests - File an issue with the Bioblend project to update their dependency requirements
4. Switch to a Modern Base Image
The root issue might be an outdated base image with frozen system packages. If you're using an old Debian/Ubuntu release (like Jessie), switching to a slim Python 2.7 base image can simplify things:
FROM python:2.7-slim # Install only necessary system packages RUN apt-get update \ && apt-get install --no-install-recommends -y wget libapache2-mod-wsgi unzip \ && apt-get clean \ && pip install flask requests bioblend fpdf
This base image comes with a more up-to-date pip and avoids the old system requests package entirely.
内容的提问来源于stack exchange,提问作者Sigvard

