python-poetry / python-poetry/poetry

CalledProcessError Immediately after install when installing dynamic versioning plugin

Open
#7,819 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/plugin-api kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • Poetry version: 1.4.2
  • Python version: 3.11.1
  • OS version and name: Windows 10; 19044.2846
  • pyproject.toml: N/A
  • [ x ] I am on the latest stable Poetry version, installed using a recommended method.
  • [ x ] I have searched the issues of this repo and believe that this is not a duplicate.
  • [ x ] I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I had a problem updating my project's dependencies. It returned CalledProcessError when I ran poetry install. I tried running it again and got a ModuleNotFound error for poetry.console. I then tried a reinstall of poetry.

I use pipx to manage my poetry installation so I ran:

pipx install poetry
poetry --version
   Poetry (version 1.4.2)
poetry self add "poetry-dynamic-versioning[plugin]"
Using version ^0.21.4 for poetry-dynamic-versioning

Updating dependencies
Resolving dependencies...

Package operations: 4 installs, 14 updates, 0 removals

  • Updating charset-normalizer (3.1.0 -> 3.0.1)
  • Updating more-itertools (9.1.0 -> 9.0.0)
  • Updating urllib3 (1.26.15 -> 1.26.14)
  • Updating zipp (3.15.0 -> 3.12.0)

  CalledProcessError

  Command '['C:\\Users\\user\\.local\\pipx\\venvs\\poetry\\Scripts\\python.exe', 'C:\\Users\\user\\.local\\pipx\\venvs\\poetry\\Lib\\site-packages\\virtualenv\\seed\\wheels\\embed\\pip-23.1-py3-none-any.whl\\pip', 'uninstall', 'charset-normalizer', '-y']' returned non-zero exit status 2.

  at C:\Program Files\Python311\Lib\subprocess.py:571 in run
       567│             # We don't call process.wait() as .__exit__ does that for us.
       568│             raise
       569│         retcode = process.poll()
       570│         if check and retcode:
    →  571│             raise CalledProcessError(retcode, process.args,
       572│                                      output=stdout, stderr=stderr)
       573│     return CompletedProcess(process.args, retcode, stdout, stderr)
       574│
       575│

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['C:\\Users\\user\\.local\\pipx\\venvs\\poetry\\Scripts\\python.exe', 'C:\\Users\\user\\.local\\pipx\\venvs\\poetry\\Lib\\site-packages\\virtualenv\\seed\\wheels\\embed\\pip-23.1-py3-none-any.whl\\pip', 'uninstall', 'charset-normalizer', '-y'] errored with the following return code 2

  Output:
  WARNING: Skipping C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\more_itertools-9.1.0.dist-info due to invalid metadata entry 'name'
  Found existing installation: charset-normalizer 3.1.0
  Uninstalling charset-normalizer-3.1.0:
    Successfully uninstalled charset-normalizer-3.1.0
  ERROR: Exception:
  Traceback (most recent call last):
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\cli\base_command.py", line 169, in exc_logging_wrapper
      status = run_func(*args)
               ^^^^^^^^^^^^^^^
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\commands\uninstall.py", line 110, in run
      uninstall_pathset.commit()
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\req\req_uninstall.py", line 432, in commit
      self._moved_paths.commit()
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\req\req_uninstall.py", line 278, in commit
      save_dir.cleanup()
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\utils\temp_dir.py", line 173, in cleanup
      rmtree(self._path)
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 291, in wrapped_f
      return self(f, *args, **kw)
             ^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 381, in __call__
      do = self.iter(retry_state=retry_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 327, in iter
      raise retry_exc.reraise()
            ^^^^^^^^^^^^^^^^^^^
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 160, in reraise
      raise self.last_attempt.result()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\concurrent\futures\_base.py", line 449, in result
      return self.__get_result()
             ^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
      raise self._exception
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 384, in __call__
      result = fn(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^
    File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\virtualenv\seed\wheels\embed\pip-23.1-py3-none-any.whl\pip\_internal\utils\misc.py", line 130, in rmtree      shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
    File "C:\Program Files\Python311\Lib\shutil.py", line 759, in rmtree
      return _rmtree_unsafe(path, onerror)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\Python311\Lib\shutil.py", line 622, in _rmtree_unsafe
      onerror(os.unlink, fullname, sys.exc_info())
    File "C:\Program Files\Python311\Lib\shutil.py", line 620, in _rmtree_unsafe
      os.unlink(fullname)
  PermissionError: [WinError 5] Access is denied: 'C:\\Users\\user\\.local\\pipx\\venvs\\poetry\\Lib\\site-packages\\~harset_normalizer\\md.cp311-win_amd64.pyd'


  at ~\.local\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env.py:1545 in _run
      1541│                 return subprocess.call(cmd, stderr=stderr, env=env, **kwargs)
      1542│             else:
      1543│                 output = subprocess.check_output(cmd, stderr=stderr, env=env, **kwargs)
      1544│         except CalledProcessError as e:
    → 1545│             raise EnvCommandError(e, input=input_)
      1546│
      1547│         return decode(output)
      1548│
      1549│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:
      

You can see it uninstalls charset-normalizer but then it throws an exception.

I then ran:

poetry --version
Traceback (most recent call last):
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\compat.py", line 11, in <module>
    import chardet
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\cleo\application.py", line 327, in run
    exit_code = self._run(io)
                ^^^^^^^^^^^^^
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py", line 188, in _run
    self._load_plugins(io)
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py", line 358, in _load_plugins
    manager.load_plugins()
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\plugins\plugin_manager.py", line 38, in load_plugins
    self._load_plugin_entry_point(ep)
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\plugins\plugin_manager.py", line 76, in _load_plugin_entry_point
    plugin = ep.load()  # type: ignore[no-untyped-call]
             ^^^^^^^^^
  File "C:\Program Files\Python311\Lib\importlib\metadata\__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry_plugin_export\plugins.py", line 7, in <module>
    from poetry_plugin_export.command import ExportCommand
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry_plugin_export\command.py", line 10, in <module>
    from poetry_plugin_export.exporter import Exporter
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry_plugin_export\exporter.py", line 11, in <module>
    from poetry.repositories.http_repository import HTTPRepository
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\repositories\http_repository.py", line 14, in <module>
    import requests
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\__init__.py", line 45, in <module>
    from .exceptions import RequestsDependencyWarning
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\exceptions.py", line 9, in <module>
    from .compat import JSONDecodeError as CompatJSONDecodeError
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\compat.py", line 13, in <module>
    import charset_normalizer as chardet
ModuleNotFoundError: No module named 'charset_normalizer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\compat.py", line 11, in <module>
    import chardet
ModuleNotFoundError: No module named 'chardet'

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 "c:\Users\user\.local\bin\poetry.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py", line 409, in main
    exit_code: int = Application().run()
                     ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\cleo\application.py", line 338, in run
    self.render_error(e, io)
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py", line 180, in render_error
    self.set_solution_provider_repository(self._get_solution_provider_repository())
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py", line 398, in _get_solution_provider_repository
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (  # noqa: E501
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\mixology\solutions\providers\__init__.py", line 3, in <module>
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\mixology\solutions\providers\python_requirement_solution_provider.py", line 9, in <module>
    from poetry.puzzle.exceptions import SolverProblemError
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\puzzle\__init__.py", line 3, in <module>
    from poetry.puzzle.solver import Solver
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\puzzle\solver.py", line 19, in <module>
    from poetry.puzzle.provider import Indicator
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\puzzle\provider.py", line 38, in <module>
    from poetry.vcs.git import Git
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\vcs\git\__init__.py", line 3, in <module>
    from poetry.vcs.git.backend import Git
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\vcs\git\backend.py", line 22, in <module>
    from poetry.utils.authenticator import get_default_authenticator
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\poetry\utils\authenticator.py", line 16, in <module>
    import requests
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\__init__.py", line 45, in <module>
    from .exceptions import RequestsDependencyWarning
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\exceptions.py", line 9, in <module>
    from .compat import JSONDecodeError as CompatJSONDecodeError
  File "C:\Users\user\.local\pipx\venvs\poetry\Lib\site-packages\requests\compat.py", line 13, in <module>
    import charset_normalizer as chardet
ModuleNotFoundError: No module named 'charset_normalizer'

I've tried reinstalling and get the same results.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with poetry/utils/env.py at the _run entry point shown in the traceback, then follow plugin loading through poetry/console/application.py and poetry/plugins/plugin_manager.py. Reproduce the pipx, Windows, and dynamic-versioning installation sequence, including the failed uninstall, and verify that Poetry remains usable after the operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.