{"id":485,"library":"faker","title":"Faker","description":"Faker is a Python package that generates fake data such as names, addresses, emails, and more, for various purposes including testing applications, populating databases, creating sample reports, and anonymizing sensitive data. It is currently on version 40.11.1 and maintains an active development cycle with frequent releases.","status":"active","version":"40.11.1","language":"python","source_language":"en","source_url":"https://github.com/joke2k/faker","tags":["data generation","testing","development","mocking","fake data"],"install":[{"cmd":"pip install Faker","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"note":"The `Factory.create()` method was the old way to instantiate a Faker generator (pre-v2.0.4) and is now superseded by directly importing and instantiating the `Faker` class.","wrong":"from faker.factory import Factory; fake = Factory.create()","symbol":"Faker","correct":"from faker import Faker"}],"quickstart":{"code":"from faker import Faker\n\nfake = Faker('en_US') # You can specify a locale\n\nprint(\"Fake Name:\", fake.name())\nprint(\"Fake Address:\", fake.address())\nprint(\"Fake Email:\", fake.email())\nprint(\"Fake Text:\", fake.text(max_nb_chars=100))","lang":"python","description":"Initialize the Faker generator and access various fake data providers as properties. Each call generates a different random value by default. Locales can be specified for region-specific data."},"warnings":[{"fix":"Upgrade Python to 3.10+ or pin Faker to an older, compatible version (e.g., `Faker==3.0.1` for Python 2).","message":"Faker dropped support for Python 2 starting from version 4.0.0, and from version 5.0.0, it only supports Python 3.8 and above. For Python 2 compatibility, install version 3.0.1.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Change `fake_instance.seed(value)` to `Faker.seed(value)`.","message":"Calling the `seed()` method on a `Faker` *instance* (e.g., `fake.seed(0)`) is deprecated and will raise a `TypeError`. Seeding should now be done using the class method `Faker.seed(0)` for consistent results across test runs.","severity":"breaking","affected_versions":">=2.0.5"},{"fix":"For strict reproducibility in tests or data generation where results must be identical across environments and time, pin the Faker library to a specific patch version in your `requirements.txt` (e.g., `Faker==40.11.1`).","message":"While `Faker.seed()` ensures reproducibility for a given Faker version, the generated data is not guaranteed to be consistent across *patch versions* (e.g., between 40.11.0 and 40.11.1) due to potential dataset updates.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Migrate any lingering `fake-factory` dependencies to `faker`.","message":"The Faker package was previously known as `fake-factory` and was deprecated by the end of 2016. Ensure your project and its dependencies do not rely on the old `fake-factory` package to avoid conflicts or outdated behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the pool of unique values is sufficiently large or handle `UniquenessException` in your code if uniqueness is critical but the pool is limited.","message":"When using the `.unique` property on a Faker generator, be aware that if it struggles to find a unique value after a number of attempts (especially with a small pool of possible values), it will raise a `UniquenessException` to prevent infinite loops.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Address pip warnings by using virtual environments or updating pip as suggested in the output, if desired. These are not Faker-specific issues.","message":"The test output contains pip warnings about running as the 'root' user and a new pip version being available. These are environmental warnings/notices and do not indicate a failure of the Faker library itself.","severity":"gotcha","affected_versions":"N/A (environment related)"}],"env_vars":null,"last_verified":"2026-05-12T14:13:23.201Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the Faker library using pip: `pip install Faker` or `python -m pip install Faker`. If using Anaconda, use `conda install -c conda-forge faker`.","cause":"The 'faker' library has not been installed in your Python environment or your interpreter is not pointing to the correct environment where it is installed.","error":"ModuleNotFoundError: No module named 'faker'"},{"fix":"Check the Faker documentation for the correct method name and ensure it's available for your chosen locale. For example, if 'zipcode' isn't working for 'pl_PL', it might be called 'postalcode' in that locale, or the provider for that data type is not loaded. If it's a known provider, ensure your Faker instance is created correctly: `from faker import Faker; fake = Faker('en_US'); print(fake.name())`.","cause":"You are trying to call a fake data generation method (e.g., 'zipcode', 'password') that does not exist, is misspelled, or is not supported by the currently selected locale.","error":"AttributeError: 'Faker' object has no attribute 'some_method_name'"},{"fix":"Change `fake.seed(0)` to `Faker.seed(0)` before creating any `Faker` instances. For example: `from faker import Faker; Faker.seed(0); fake = Faker(); print(fake.name())`.","cause":"In newer versions of Faker (since v3.0.0), the `seed()` method is intended to be called as a class method on `Faker` itself, not on an instance of `Faker`, to ensure consistent seeding across all generators.","error":"TypeError: Calling `.seed()` on instances is deprecated. Use the class method `Faker.seed()` instead."},{"fix":"Rename your local Python file or module that has the name 'faker.py' to something else (e.g., 'my_faker_script.py') to avoid the naming conflict.","cause":"This error typically occurs when you have named one of your own Python files or modules 'faker.py', which conflicts with the installed 'faker' library, causing Python to try importing from your local file instead of the package.","error":"ImportError: cannot import name 'Faker' from partially initialized module 'faker'"},{"fix":"Use a supported locale code. Refer to the Faker documentation for a list of available locales (e.g., 'en_US', 'fr_FR', 'it_IT'). For example: `from faker import Faker; fake = Faker('fr_FR'); print(fake.name())`.","cause":"You have specified a locale code (e.g., 'unsupported_locale_code') when initializing Faker that is not recognized or supported by the library.","error":"ValueError: No locale found for 'unsupported_locale_code'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.24,"mem_mb":8.6,"disk_size":"42.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.17,"mem_mb":8.6,"disk_size":"43M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.33,"mem_mb":8.8,"disk_size":"43.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":8.8,"disk_size":"44M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":8.5,"disk_size":"35.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":8.5,"disk_size":"35M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":8.8,"disk_size":"34.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":8.8,"disk_size":"35M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.21,"mem_mb":8.5,"disk_size":"42.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":8.5,"disk_size":"43M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}