Skip to content

Regression: local installation in custom path no longer working after sys.path cleanup #1350

Closed

Description

@upekkha

The de-duplicating sys.path PR #1248 seems to break "local" installations of mitogen into a custom folder.

Consider installing mitogen without pip, either with git clone or downloading and extracting the release tar into /custom/path/to/mitogen.

Then take any minimal Ansible playbook and adapt ansible.cfg to use that mitogen, as explained in the official docs.

[defaults]
strategy_plugins = /custom/path/to/mitogen/ansible_mitogen/plugins/strategy
strategy = mitogen_linear

Ansible fails to correctly import the mitogen modules:

ansible-playbook -i inventory playbook.yml

PLAY [all] ******************************************************************************************************************
[ERROR]: Unexpected Exception, this is probably a bug: No module named 'ansible_mitogen'

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/cli/__init__.py", line 660, in cli_executor
    exit_code = cli.run()
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/cli/playbook.py", line 153, in run
    results = pbex.run()
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/executor/playbook_executor.py", line 188, in run
    result = self._tqm.run(play=play)
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/executor/task_queue_manager.py", line 320, in run
    strategy = strategy_loader.get(new_play.strategy, self)
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/plugins/loader.py", line 979, in get
    ctx = self.get_with_context(name, *args, **kwargs)
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/plugins/loader.py", line 1024, in get_with_context
    self._module_cache[path] = self._load_module_source(python_module_name=plugin_load_context._python_module_name, path=path)
                               ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/plugins/loader.py", line 943, in _load_module_source
    spec.loader.exec_module(module)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 762, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/custom/path/to/mitogen/ansible_mitogen/plugins/strategy/mitogen_linear.py", line 48, in <module>
    import ansible_mitogen.loaders
ModuleNotFoundError: No module named 'ansible_mitogen'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.14/site-packages/ansible/cli/__init__.py", line 669, in cli_executor
    raise AnsibleError("Unexpected Exception, this is probably a bug.") from ex
ansible.errors.AnsibleError: Unexpected Exception, this is probably a bug: No module named 'ansible_mitogen'

Reverting the commit 6145508 for only the file ansible_mitogen/plugins/strategy/mitogen_linear.py already fixes this import error (and successfully runs the minimal playbook).

Also note that a pip install mitogen installation is not affected by this regression. For instance using strategy_plugins = .venv/lib/python3.14/site-packages/ansible_mitogen/plugins/strategy works without issues.

Versions used:
python 3.14.0
ansible 12.1.0
ansible-core 2.19.3

Activity

  1. added
    bugCode feature that hinders desired execution outcome
    affects-0.3Issues related to 0.3.X Mitogen releases
    on Oct 31, 2025
  2. moreati commented on Oct 31, 2025

    @moreati
    Member

    D'oh! Sorry for that. Please use 0.3.29 for now. It may be a week or so before I can get a fix out

  3. moreati commented on Nov 5, 2025

    @moreati
    Member

    Please try 85069b2, if it works for you then I'll put out a new release.

  4. upekkha commented on Nov 5, 2025

    @upekkha
    ContributorAuthor

    Thanks. Yes that commit fixes the problems.

  5. moreati commented on Nov 5, 2025

    @moreati
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-0.3Issues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions