{"id":8650,"library":"slugify","title":"slugify (Legacy Python 2)","description":"Slugify (version 0.0.1) is a legacy Python library for generating URL-friendly 'slugs' from strings, primarily for Latin-based scripts. Inspired by Django's `slugify` template filter, it provides a Python function and a command-line tool. The library is considered abandoned and only officially supports Python 2.","status":"abandoned","version":"0.0.1","language":"en","source_language":"en","source_url":"http://github.com/zacharyvoase/slugify","tags":["string-manipulation","slug","url","legacy","python2","abandoned"],"install":[{"cmd":"pip install slugify","lang":"bash","label":"Install for Python 2"}],"dependencies":[],"imports":[{"note":"This specific 'slugify' package imports directly as 'slugify', which conflicts with the more common 'python-slugify' package if both are installed.","wrong":"from python_slugify import slugify","symbol":"slugify","correct":"from slugify import slugify"}],"quickstart":{"code":"import sys\n# This library is for Python 2. Running in Python 3 will cause a NameError.\n# To test, ensure you are in a Python 2 environment.\nif sys.version_info.major == 2:\n    from slugify import slugify\n    text_to_slug = u\"Hello World! This is a Test 123\"\n    slugged_text = slugify(text_to_slug)\n    print(\"Original:\", text_to_slug)\n    print(\"Slugged:\", slugged_text)\nelse:\n    print(\"This quickstart requires Python 2. Current Python version is\", sys.version)","lang":"python","description":"A simple example demonstrating the use of the `slugify` function. Note that this library is Python 2 only. Running it in Python 3 will result in errors related to the `unicode()` function."},"warnings":[{"fix":"Use a Python 2 interpreter or, preferably, switch to a modern, Python 3-compatible slugification library like `python-slugify`.","message":"This `slugify` library (version 0.0.1) is only compatible with Python 2. Attempting to use it in a Python 3 environment will lead to runtime errors, most notably `NameError: name 'unicode' is not defined`.","severity":"breaking","affected_versions":"0.0.1 and likely all subsequent (if any) versions; affects Python 3 environments"},{"fix":"Always uninstall `slugify` (the 0.0.1 package) if you intend to use `python-slugify`. Ensure you only have one slugification library installed if they share the same top-level import name.","message":"There is a significant name collision with the more actively maintained and widely used `python-slugify` library. Both packages attempt to expose the `slugify` function via `from slugify import slugify` which can lead to unpredictable behavior and importing the wrong library if both are installed.","severity":"gotcha","affected_versions":"All versions of `slugify` (0.0.1) and `python-slugify` when installed concurrently."},{"fix":"For robust Unicode support, use `python-slugify`, which has built-in or optional dependencies for comprehensive transliteration (e.g., `text-unidecode` or `Unidecode`).","message":"This library is designed for Latin-based scripts only and offers limited to no support for Unicode characters or internationalization. Non-Latin characters will often be stripped or replaced incorrectly, resulting in unusable slugs.","severity":"gotcha","affected_versions":"0.0.1"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run your code in a Python 2 environment. If you need Python 3 support, use `pip uninstall slugify` and then install a Python 3 compatible alternative, such as `pip install python-slugify`.","cause":"The `slugify` library (0.0.1) uses Python 2's `unicode()` built-in function, which was removed in Python 3.","error":"NameError: name 'unicode' is not defined"},{"fix":"Identify which 'slugify' package you intend to use. If it's `python-slugify`, then `pip uninstall slugify` (the old package) and ensure only `python-slugify` is installed.","cause":"You likely have multiple packages providing a 'slugify' module (e.g., both 'slugify' and 'python-slugify') installed. The Python interpreter might be importing the wrong one due to package naming conflicts.","error":"from slugify import slugify\nAttributeError: module 'slugify' has no attribute 'slugify' (or similar unexpected behavior)"},{"fix":"For international character support, switch to `python-slugify`. It offers more comprehensive Unicode handling, often leveraging libraries like `text-unidecode` for accurate transliteration.","cause":"The `slugify` library (0.0.1) lacks proper Unicode transliteration and is designed for Latin-based scripts. It often replaces non-Latin characters with hyphens or removes them.","error":"slugify('你好世界') -> '---' (or similar unhelpful output for non-Latin characters)"}]}