pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.1k stars 309 forks source link

env issue ModuleNotFoundError: No module named 'pip._vendor.cachecontrol.caches' #1681

Open topherbuckley opened 3 months ago

topherbuckley commented 3 months ago

I'm having trouble using even basic env functionality.

Steps to reproduce

  1. pip install hatch (1.12.0 installed by default on current python 3.10.12, pip 24.2)
  2. mkdir tmp && cd tmp
  3. hatch run python -V returns Python 3.10.12 as expected
  4. hatch new --init give `tmp as project name and empty description. This writes default pyproject.toml to current directory.
  5. hatch env create fails with:
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/__main__.py", line 24, in <module>
    sys.exit(_main())
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 77, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/commands/__init__.py", line 114, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 15, in <module>
    from pip._internal.cli.req_command import (
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.index.collector import LinkCollector
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/index/collector.py", line 37, in <module>
    from pip._internal.network.session import PipSession
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/network/session.py", line 44, in <module>
    from pip._internal.network.cache import SafeFileCache
  File "/home/bo/.local/share/hatch/env/virtual/tmp/979qH29C/tmp/lib/python3.10/site-packages/pip/_internal/network/cache.py", line 9, in <module>
    from pip._vendor.cachecontrol.caches import FileCache
ModuleNotFoundError: No module named 'pip._vendor.cachecontrol.caches'

I note I have no issues using pip outside of hatch that I can tell but have uninstalled and resintalled both python3 and python3-pip via apt just in case.