-
Notifications
You must be signed in to change notification settings - Fork 659
Description
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
- Install
textract>=1.6.5(which constrainssixto~=1.12.0) - Try to import
six.movesdirectly:from six.moves import _thread - Observe
ModuleNotFoundError: No module named 'six.moves'
Workaround
Users can work around this by:
- 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
- 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