Skip to content

When upgrading package to Python 3.12: Fatal error: TypeError: rmtree() got an unexpected keyword argument 'onexc' #1090

@corneliusroemer

Description

@corneliusroemer

Describe the bug
Getting fatal error when force installing over existing installation.

pipx install --python python3.12 visidata --force

Installing to existing venv 'visidata'
Fatal error from pip prevented installation. Full pip output in file:
    /Users/corneliusromer/.local/pipx/logs/cmd_2023-10-16_15.54.17_pip_errors.log

Some possibly relevant errors from pip install:
    TypeError: rmtree() got an unexpected keyword argument 'onexc'

⚠️  Not removing existing venv /Users/corneliusromer/.local/pipx/venvs/visidata because it was not created in this session
Error installing visidata.

Full logs:

PIP STDOUT
----------
Requirement already satisfied: visidata in /Users/corneliusromer/.local/pipx/venvs/visidata/lib/python3.12/site-packages (2.11.1)
Requirement already satisfied: python-dateutil in /Users/corneliusromer/.local/pipx/venvs/visidata/lib/python3.12/site-packages (from visidata) (2.8.2)
Requirement already satisfied: importlib-metadata>=3.6 in /Users/corneliusromer/.local/pipx/venvs/visidata/lib/python3.12/site-packages (from visidata) (6.8.0)
Requirement already satisfied: zipp>=0.5 in /Users/corneliusromer/.local/pipx/venvs/visidata/lib/python3.12/site-packages (from importlib-metadata>=3.6->visidata) (3.17.0)
Requirement already satisfied: six>=1.5 in /Users/corneliusromer/.local/pipx/venvs/visidata/lib/python3.12/site-packages (from python-dateutil->visidata) (1.16.0)

PIP STDERR
----------
Traceback (most recent call last):
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 45, in global_tempdir_manager
    yield
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/operations/build/build_tracker.py", line 44, in get_build_tracker
    with contextlib.ExitStack() as ctx:
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 589, in __exit__
    raise exc_details[1]
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 169, in __exit__
    self.cleanup()
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 212, in cleanup
    rmtree(self._path, ignore_errors=False)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 291, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 381, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 327, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 160, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 384, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 148, in rmtree
    shutil.rmtree(dir, onexc=handler)
TypeError: rmtree() got an unexpected keyword argument 'onexc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 169, in __exit__
    self.cleanup()
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 212, in cleanup
    rmtree(self._path, ignore_errors=False)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 291, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 381, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 327, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 160, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 384, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 148, in rmtree
    shutil.rmtree(dir, onexc=handler)
TypeError: rmtree() got an unexpected keyword argument 'onexc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 169, in __exit__
    self.cleanup()
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 212, in cleanup
    rmtree(self._path, ignore_errors=False)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 291, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 381, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 327, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 160, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 384, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 148, in rmtree
    shutil.rmtree(dir, onexc=handler)
TypeError: rmtree() got an unexpected keyword argument 'onexc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/__main__.py", line 24, in <module>
    sys.exit(_main())
             ^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/main.py", line 79, in main
    return command.main(cmd_args)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 100, in main
    with self.main_context():
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/command_context.py", line 19, in main_context
    with self._main_context:
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 589, in __exit__
    raise exc_details[1]
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 42, in global_tempdir_manager
    with ExitStack() as stack:
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 589, in __exit__
    raise exc_details[1]
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 574, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 169, in __exit__
    self.cleanup()
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.py", line 212, in cleanup
    rmtree(self._path, ignore_errors=False)
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 291, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 381, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 327, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 160, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/tenacity/__init__.py", line 384, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 148, in rmtree
    shutil.rmtree(dir, onexc=handler)
TypeError: rmtree() got an unexpected keyword argument 'onexc'

How to reproduce

  1. Install package with one python version pipx install --python python3.11 visidata
  2. Install same package but with different python version pipx install --python python3.12 visidata --force

Expected behavior
I get some better feedback on what pipx can or cannot do. I shouldn't get a type error which is not helpful for the end user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions