ics is a Python library for parsing, creating, and manipulating iCalendar files (RFC 5545). It provides an object-oriented API to work with Calendars, Events, Todos, Alarms, and other iCalendar components. The current version is 0.7.2, and releases occur periodically for bug fixes, minor enhancements, and major version upgrades that introduce breaking changes.
pip install icsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a new iCalendar object, add events with basic properties like name, start time, and duration, and then output the calendar as an iCalendar string. You can also save it to a .ics file.
Upgrade to Python 3.5+ if you are on an older Python 2.x environment.
Ensure your environment is Python 3.6+ and install `ics` which will pull `TatSu`. Update code from `._unused` to `.extra`.
Instead of `e.organizer = 'mailto:test@example.com'`, use `from ics import Organizer; e.organizer = Organizer(email='test@example.com')`.
Review the upcoming 0.8 release notes for changes to these methods. Consider preparing for potential adaptation of how calendars are serialized or iterated.
Ensure `attrs` is up-to-date in your environment, ideally `pip install 'attrs>=19.1.0'` before installing `ics` or allow `pip install ics` to handle the dependency update.
Ensure the library is installed using pip: `pip install ics`
Ensure all `datetime` objects used with `ics` are timezone-aware and, ideally, in UTC. Use libraries like `pytz` or `dateutil` to create or convert `datetime` objects to be timezone-aware. Example: `from datetime import datetime, timezone; event.begin = datetime(2023, 1, 1, 10, 0, 0, tzinfo=timezone.utc)`
Ensure that properties like `event.name`, `event.description`, etc., are assigned string values. Convert non-string data to strings explicitly before assignment. Example: `e.name = str(i)` instead of `e.name = i`
If you intend to use the `ics` library, import `Calendar` from it directly: `from ics import Calendar`. If you truly mean to use the `icalendar` library, ensure it is installed (`pip install icalendar`) and that your code correctly uses its API.