Mimesis is a powerful and fast fake data generator for Python. It provides data for a variety of purposes, including populating databases, creating test data, and anonymizing existing datasets. As of version 19.1.0, it supports numerous locales and data types. The library maintains an active development pace, with regular minor and major releases introducing new features, locales, and performance improvements, often on a monthly or bi-monthly cadence.
pip install mimesisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a `Generic` data generator with a specific locale and generate various types of fake data. It also shows direct initialization of a specific provider like `Person`.
Instead of relying on the internal plugin, users should create project-specific fixtures and utilize the `Field` class for data generation within their tests.
If you were using `mimesis-factory`, you should now import factory-related functionalities directly from `mimesis` (e.g., `from mimesis.builtins import MimesisBaseFactory`) and adapt your code accordingly.
For generating random integers that previously `age()` or `work_experience()` might have provided, use `person.random.randint(min_value, max_value)` instead.
If your previous code relied on the cryptographically secure randomness provided by `secrets` for the `Cryptographic` provider, be aware that this has changed. Ensure your usage aligns with the new seedable random behavior, especially for security-sensitive applications or when reproducible results are needed.
If upgrading from an older version, update your code to use the standard providers directly (e.g., `Person`, `Address`). If the functionality is not directly available, implement a custom field handler. If you are using Python 3.8 or 3.9, the last compatible Mimesis version is 11.1.0.
Ensure your custom provider class (e.g., `MyCustomProvider`) inherits from `mimesis.providers.BaseProvider`.
Consult the Mimesis documentation for a list of all supported locales and use one of the available `Locale` enums (e.g., `Locale.EN`, `Locale.RU`) when initializing your provider.
Remove the `locale` argument when initializing locale-independent providers (e.g., `Code()`, `Random()`). When using `Generic()`, Mimesis automatically detects and handles locale dependencies for its sub-providers.