Skip to content

Conversation

@evangeloskp
Copy link
Contributor

Problem

When installing django-tailwind without optional dependencies, users encounter an ImportError:

ModuleNotFoundError: No module named 'distlib'

This occurs because:

  • distlib is not listed as a required dependency in pyproject.toml (only django and
    pytailwindcss are)
  • distlib is only available as a transitive dependency through the optional cookiecutter package
    (cookiecuttervirtualenvdistlib)
  • The management command imports from distlib.compat import raw_input at the module level

I encountered this issue when building a Docker image with pip install django-tailwind, which
doesn't include optional dependencies.

Solution

Since django-tailwind requires Python 3.11+ (as specified in pyproject.toml), we can safely use
Python 3's built-in input() function instead of the Python 2/3 compatibility wrapper.

Changes made:

  • Removed from distlib.compat import raw_input import
  • Replaced all 3 occurrences of raw_input() with input()

In Python 3, input() behaves identically to Python 2's raw_input() (returns a string without
evaluation).

Testing

  • ✅ All existing tests pass (uv run pytest)
  • ✅ Code formatted with ruff
  • ✅ Verified the import no longer depends on an unlisted dependency

This fix ensures users can install and use django-tailwind with only the required dependencies
listed in pyproject.toml.

…nput()

The distlib package is not listed as a required dependency in pyproject.toml,
causing ImportError when users install django-tailwind without the optional
cookiecutter dependency (which transitively provides distlib via virtualenv).

Since the package requires Python 3.11+ (as specified in pyproject.toml),
we can safely use the built-in input() function instead of the Python 2/3
compatibility wrapper from distlib.

This change removes the unnecessary distlib import and replaces all three
occurrences of raw_input() with input() in the tailwind management command.
@timonweb timonweb merged commit 46fb9a9 into timonweb:master Nov 8, 2025
5 checks passed
@timonweb
Copy link
Owner

timonweb commented Nov 8, 2025

@evangeloskp thank you for catching and fixing this, I had no idea about raw_input vs input, great fix!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants