Install & Compatibility
Where this runs
tested against v2.3.2.post1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.018s · 65.6MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.016s · 18MB
65MB installed
● package 65MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Hijri, Gregorian
✓ from hijri_converter import Hijri, Gregorian
✗ from hijridate import Hijri, Gregorian
This is the correct import for the deprecated 'hijri-converter' package. For new projects, use 'from hijridate import Hijri, Gregorian' as the API is identical but the package name differs.
This example demonstrates how to convert dates between Hijri and Gregorian calendars using the `Hijri` and `Gregorian` classes. Both date systems allow conversion to the other.
from hijri_converter import Hijri, Gregorian
# Convert a Hijri date to Gregorian
h_date = Hijri(1403, 2, 17)
g_date = h_date.to_gregorian()
print(f"Hijri 1403-02-17 is Gregorian: {g_date}")
# Convert a Gregorian date to Hijri
g_date_input = Gregorian(1982, 12, 2)
h_date_output = g_date_input.to_hijri()
print(f"Gregorian 1982-12-02 is Hijri: {h_date_output}")
Debug
Known issues
breakingThe `hijri-converter` package is officially deprecated and will not receive any further updates. Users are strongly advised to migrate to the `hijridate` package.fixUninstall `hijri-converter` and install `hijridate`. The API remains identical, so import statements need to change from `from hijri_converter import ...` to `from hijridate import ...`.
affects: All versions (from 2.3.2.post1 onwards)
gotchaThe converter has a limited date range, supporting dates from 1343 AH to 1500 AH (approximately August 1, 1924 CE to November 16, 2077 CE). Dates outside this range may not be converted accurately or may raise errors.fixEnsure input dates fall within the supported range. For dates outside this range, alternative conversion methods or libraries may be required.
affects: All versions
gotchaThe conversion is based on astronomical calculations for the Umm al-Qura calendar and is not intended for religious purposes where the sighting of the lunar crescent is preferred for determining the start of Hijri months. Local moon sighting can cause a one-day difference.fixFor religious observances, always consult local religious authorities or confirmed moon sighting announcements rather than relying solely on programmatic conversion.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'hijri_converter'
The Python interpreter cannot find the 'hijri_converter' package, likely because it was not installed, installed incorrectly, or there's a typo in the import statement.
fixEnsure the package is correctly installed using pip: `pip install hijri-converter` or, if already installed, check your virtual environment or Python path. Sometimes, the installed package name on the file system might differ from the import name (though less common for this specific package, it's a general troubleshooting step for ModuleNotFoundError).
AttributeError: module 'hijri_converter' has no attribute 'convert'
This error occurs when a user tries to access `convert.Hijri` or `convert.Gregorian` after importing `from hijri_converter import convert`. The `Hijri` and `Gregorian` classes are directly available from the `hijri_converter` module, not nested under a 'convert' object.
fixImport the `Hijri` and `Gregorian` classes directly from the package: `from hijri_converter import Hijri, Gregorian`. Then use them as `Hijri(year, month, day)` or `Gregorian(year, month, day)`.
ValueError: day must be in 1..29 for month (or 1..30)
This error indicates that an invalid day was provided for a given month in the Hijri date conversion. The Umm al-Qura calendar, which `hijri-converter` is based on, has specific month lengths (29 or 30 days) that are strictly validated.
fixProvide a valid day number for the specified month and year according to the Umm al-Qura calendar. You may need to cross-reference with an accurate Hijri calendar or ensure your input data respects the calendar's rules. The library includes date validation by default; for example, `Hijri(1433, 12, 30)` would fail if Dhu al-Hijjah 1433 AH only had 29 days.
TypeError: 'unicode' object is not callable
This error often occurs when attempting to call a string variable as if it were a function, especially in older Python 2 code or when mixing string manipulation with object instantiation. In the context of date conversion, it might stem from incorrectly parsing date components from a string and then trying to use those string components directly as callable objects instead of arguments to the date constructor.
fixEnsure that date components (year, month, day) extracted from strings are converted to integers before being passed to the `Hijri` or `Gregorian` class constructors. For example, if `yr_str`, `mth_str`, `day_str` are strings, use `Hijri(int(yr_str), int(mth_str), int(day_str))`.
hijri-converter is deprecated
The `hijri-converter` package is no longer actively maintained and has been superseded by the `hijridate` package. While not a runtime error, continued use may lead to unaddressed bugs or lack of compatibility with newer Python versions and operating systems.
fixMigrate your project to use the `hijridate` package. Install it with `pip install hijridate` and update your import statements from `from hijri_converter import Hijri, Gregorian` to `from hijridate import Hijri, Gregorian`. The API remains largely identical.
Upgrade
Version history
2.3.2.post1latest on PyPI · released Jul 27, 2025
Audit
Dependencies
PythonrequiredRequired runtime environment.