Skip to content

six.moves import fails with textract's six constraint #546

@rosielarose

Description

@rosielarose

Describe the bug
The textract package constrains six to ~=1.12.0 (>=1.12.0,<1.13), but six version 1.12.0 has a known issue where the meta path importer doesn't work correctly for direct imports of six.moves, even though six.moves is accessible as an attribute of the six module.

This causes ModuleNotFoundError: No module named 'six.moves' when other packages (like python-dateutil) try to import six.moves directly.

The expected behavior is that six.moves should be importable directly, as it works in newer versions of six.

To Reproduce

  1. Install textract>=1.6.5 (which constrains six to ~=1.12.0)
  2. Try to import six.moves directly: from six.moves import _thread
  3. Observe ModuleNotFoundError: No module named 'six.moves'

Workaround
Users can work around this by:

  1. Adding a monkey patch in their main module:
    import six
    import sys
    if 'six.moves' not in sys.modules:
        sys.modules['six.moves'] = six.moves
  2. Or downgrading to textract==1.6.4 (which has no dependency constraints)

Suggested Fix
Update the six constraint in textract to allow newer versions (e.g., six>=1.12.0 instead of six~=1.12.0), as newer versions of six have fixed this import issue.

Desktop (please complete the following information):

  • OS: MacOS 15.5
  • Textract version 1.6.5, six 1.12.0 (constrained by textract
  • Python version 3.12
  • Virtual environment: yes

Additional context
This affects any project that uses textract and has dependencies that import six.moves
The issue is particularly problematic in modern Python environments where six.moves imports are common
The constraint seems unnecessarily restrictive since newer versions of six are backward compatible

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