René's URL Explorer Experiment


Title: Python pip — Container ImportError from Global Packages

Open Graph Title: Python pip — Container ImportError from Global Packages

Description: Container exited with ImportError: cannot import name 'Session' from 'requests' due to global packages. Fix by using venv and pip-compile pinning.

Open Graph Description: Container exited with ImportError: cannot import name 'Session' from 'requests' due to global packages. Fix by using venv and pip-compile pinning.

Opengraph URL: https://thecodeforge.io/python/python-packaging-pip/

direct link

Domain: thecodeforge.io


Hey, it has json ld scripts:
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://thecodeforge.io/python/python-packaging-pip/"
  },
  "headline": "Python pip — Container ImportError from Global Packages",
  "description": "Container exited with ImportError: cannot import name 'Session' from 'requests' due to global packages. Fix by using venv and pip-compile pinning.",
  "keywords": "Python pip — Container ImportError from Global Packages, Python, Intermediate, Advanced Python, Container exited with ImportError: cannot import name 'Session' from 'requests' due to global packages. Fix by using venv and pip-compile pinning.",
  "proficiencyLevel": "Intermediate",
  "author": {
    "@type": "Person",
    "@id": "https://thecodeforge.io/about/#naren",
    "name": "Naren",
    "url": "https://thecodeforge.io/about/"
  },
  "publisher": {
    "@type": "Organization",
    "@id": "https://thecodeforge.io/#org",
    "name": "TheCodeForge",
    "url": "https://thecodeforge.io",
    "logo": {"@type": "ImageObject", "url": "https://thecodeforge.io/assets/og-image.png"}
  },
  "datePublished": "2026-03-05T00:00:00+00:00",
  "dateModified": "2026-09-26T00:00:00+00:00",
  "url": "https://thecodeforge.io/python/python-packaging-pip/",
  "inLanguage": "en",
  "educationalLevel": "Intermediate",
  "image": "https://thecodeforge.io/assets/og-image.png",
  "isPartOf": {"@id": "https://thecodeforge.io/#website"}
}
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {"@type": "ListItem", "position": 1, "name": "Home", "item": "https://thecodeforge.io/"},
    {"@type": "ListItem", "position": 2, "name": "Python", "item": "https://thecodeforge.io/python/"},
    {"@type": "ListItem", "position": 3, "name": "Python pip — Container ImportError from Global Packages", "item": "https://thecodeforge.io/python/python-packaging-pip/"}
  ]
}
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is the difference between pip install and pip install -e?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Regular `pip install .` copies your package files into site-packages — any changes you make to your source code after that are not reflected until you reinstall. `pip install -e .` (editable mode) installs the package in development mode by creating a link that points directly to your source folder — edit a file and the change is immediately live without reinstalling. Use -e during active development so you can test changes instantly. Use regular install for final testing and production deployments to ensure you're testing the actual installed package rather than a live source tree."
      }
    },
    {
      "@type": "Question",
      "name": "Should I commit my virtual environment folder to Git?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Never. The venv folder contains compiled binary files that are specific to your operating system and CPU architecture — a venv created on macOS will not work on Linux, and vice versa. It can easily exceed 500MB for projects with heavy dependencies. It bloats your repository and will cause binary merge conflicts. Add 'venv/' and '.venv/' to your .gitignore immediately when starting any project. Commit requirements.txt or pyproject.toml instead — any developer can recreate the identical environment with two commands."
      }
    },
    {
      "@type": "Question",
      "name": "What is the difference between install_requires in setup.py and dependencies in pyproject.toml?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "They're functionally equivalent — both declare the packages your library needs to work. The difference is in the file format and what it enables. pyproject.toml is the modern standard endorsed by PEP 517/518 and understood by all current build tools including pip, hatch, flit, poetry, and uv. setup.py's install_requires is the legacy approach and is actively being deprecated. For any project started in 2024 or later, use pyproject.toml. For existing projects using setup.py, migration is straightforward and the Python Packaging Authority recommends it."
      }
    },
    {
      "@type": "Question",
      "name": "What is a wheel (.whl) file and why is it faster than installing from source?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "A wheel is a pre-built binary distribution in ZIP format (.whl) that pip can install by simply extracting files into site-packages — no compilation, no running setup code, no build tools required. Installing from a source distribution requires the build backend to compile the code on the user's machine, which takes seconds for pure Python packages and potentially minutes for packages with C or Rust extensions like numpy, pandas, or pydantic. Wheels make the typical install experience nearly instant and eliminate the need for users to have a compiler installed."
      }
    },
    {
      "@type": "Question",
      "name": "How do optional dependency groups work in pyproject.toml?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Define them under [project.optional-dependencies] with a group name. For example: `dev = ['pytest>=7.0', 'black>=24.0']`. Users install the group with `pip install weather-fetcher[dev]`. Multiple groups are supported and can be combined: `pip install weather-fetcher[dev,docs]`. This keeps development and documentation tools out of your main dependency list, so end users only install what they actually need to use your package — not your testing framework or code formatter."
      }
    }
  ]
}

og:typewebsite
og:imagehttps://thecodeforge.io/assets/og-image.png
og:image:width1200
og:image:height630

Links:

TheCodeForge https://thecodeforge.io/
Pythonhttps://thecodeforge.io/python/
Buy me a coffee https://ko-fi.com/thecodeforge
1Iterators and Iterables in Pythonhttps://thecodeforge.io/python/iterators-iterables-python/
2Coroutines and asyncio in Pythonhttps://thecodeforge.io/python/coroutines-asyncio-python/
3Metaclasses in Pythonhttps://thecodeforge.io/python/metaclasses-python/
4Memory Management in Pythonhttps://thecodeforge.io/python/memory-management-python/
5Python Descriptorshttps://thecodeforge.io/python/python-descriptors/
6Type Hints in Pythonhttps://thecodeforge.io/python/type-hints-python/
7Unit Testing with pytesthttps://thecodeforge.io/python/unit-testing-pytest/
8Virtual Environments in Pythonhttps://thecodeforge.io/python/virtual-environments-python/
9Python Packaging and piphttps://thecodeforge.io/python/python-packaging-pip/
10GIL — Global Interpreter Lockhttps://thecodeforge.io/python/global-interpreter-lock-python/
11Python Slotshttps://thecodeforge.io/python/python-slots/
12Abstract Base Classes in Pythonhttps://thecodeforge.io/python/abstract-base-classes-python/
13Python Design Patternshttps://thecodeforge.io/python/python-design-patterns/
14Python Performance Optimisationhttps://thecodeforge.io/python/python-performance-optimisation/
15Python Concurrency — asyncio Deep Divehttps://thecodeforge.io/python/python-asyncio-deep-dive/
16Python Weak Referenceshttps://thecodeforge.io/python/python-weak-references/
17The Zen of Python: 19 Principles That Explain Every Design Decisionhttps://thecodeforge.io/python/zen-of-python/
← Back to Python track https://thecodeforge.io/python/
Homehttps://thecodeforge.io/
Pythonhttps://thecodeforge.io/python/
Follow https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
 ● Production Incidenthttps://thecodeforge.io/python/python-packaging-pip/#v2-production-incident
 🔎 Debug Guidehttps://thecodeforge.io/python/python-packaging-pip/#v2-debug-guide
 ⚙ Triage Commandshttps://thecodeforge.io/python/python-packaging-pip/#v2-triage-commands
Pythonhttps://thecodeforge.io/python/introduction-python/
machinehttps://thecodeforge.io/ml-ai/introduction-machine-learning/
Virtual environmentshttps://thecodeforge.io/python/virtual-environments-python/
containerhttps://thecodeforge.io/dsa/container-with-most-water/
Dockerhttps://thecodeforge.io/devops/introduction-docker/
Python installationhttps://thecodeforge.io/python/python-installation-setup/
CI/CD pipelinehttps://thecodeforge.io/devops/cicd-pipeline-best-practices/
Dockerfilehttps://thecodeforge.io/devops/dockerfile-explained/
OpenCVhttps://thecodeforge.io/ml-ai/opencv-basics/
stackhttps://thecodeforge.io/dsa/stack-data-structure/
→pip Error: Cannot Uninstall distutils Package FixUse a virtualenv instead of forcing pip past distutils errors. Covers OS packages, ignore-installed risks, and PEP 668 rhttps://thecodeforge.io/python/pip-cannot-uninstall-distutils-installed/
→Python Virtual Environments — Django 1.11 & 4.0 ConflictOne server running Django 1.11 and 4.0 causes AttributeError crashes. Isolate per app with virtual environments to avoidhttps://thecodeforge.io/python/virtual-environments-python/
→ModuleNotFoundError: Fix Python Imports That FailModuleNotFoundError means Python searched sys.path and found no module by that name. Match pip to your interpreter and fhttps://thecodeforge.io/python/python-modulenotfounderror/
RLHF — Reinforcement Learning from Human FeedbackAdvancedhttps://thecodeforge.io/ml-ai/rlhf-explained/
Follow https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
←PreviousVirtual Environments in Pythonhttps://thecodeforge.io/python/virtual-environments-python/
NextGIL — Global Interpreter Lock→https://thecodeforge.io/python/global-interpreter-lock-python/
LinkedIn https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
Facebook https://www.facebook.com/profile.php?id=61583020033815
YouTube https://www.youtube.com/channel/UCMar7CF2EmCF1I2tw1tNVuQ
Javahttps://thecodeforge.io/java/
Pythonhttps://thecodeforge.io/python/
C / C++https://thecodeforge.io/c-cpp/
JavaScripthttps://thecodeforge.io/javascript/
DSAhttps://thecodeforge.io/dsa/
Databasehttps://thecodeforge.io/database/
System Designhttps://thecodeforge.io/system-design/
DevOpshttps://thecodeforge.io/devops/
C# / .NEThttps://thecodeforge.io/csharp/
PHPhttps://thecodeforge.io/php/
ML / AIhttps://thecodeforge.io/ml-ai/
Interviewhttps://thecodeforge.io/interview/
CS Fundamentalshttps://thecodeforge.io/cs-fundamentals/
Rusthttps://thecodeforge.io/rust/
Toolshttps://thecodeforge.io/tools/
Cheatsheetshttps://thecodeforge.io/cheatsheets/
Mobilehttps://thecodeforge.io/mobile/
Data Analyticshttps://thecodeforge.io/data-analytics/
Securityhttps://thecodeforge.io/security/
Frontendhttps://thecodeforge.io/frontend/
Data Engineeringhttps://thecodeforge.io/data-engineering/
Testinghttps://thecodeforge.io/testing/
Cloudhttps://thecodeforge.io/cloud/
Observabilityhttps://thecodeforge.io/observability/
Web Platformhttps://thecodeforge.io/web-platform/
🧯 Errors Explainedhttps://thecodeforge.io/errors/
⚒ Blueprintshttps://thecodeforge.io/blueprints/
⌨ Practicehttps://thecodeforge.io/practice/
Interview Prephttps://thecodeforge.io/interview/
DSA Problemshttps://thecodeforge.io/dsa/
Developer Toolshttps://thecodeforge.io/tools/
Cheat Sheetshttps://thecodeforge.io/cheatsheets/
Abouthttps://thecodeforge.io/about/
Sitemaphttps://thecodeforge.io/sitemap.xml
Privacyhttps://thecodeforge.io/privacy.html

Viewport: width=device-width, initial-scale=1.0

Robots: max-image-preview:large


URLs of crawlers that visited me.