Skip to main content

platformdirs

PyPI version Python versions CI Downloads

A Python package for determining platform-specific directories (e.g. user data, config, cache, logs). Handles the differences between macOS, Windows, Linux/Unix, and Android so you don't have to.

Quick start

from platformdirs import PlatformDirs

dirs = PlatformDirs("MyApp", "MyCompany")
dirs.user_data_dir  # ~/.local/share/MyApp (Linux)
dirs.user_config_dir  # ~/.config/MyApp (Linux)
dirs.user_cache_dir  # ~/.cache/MyApp (Linux)
dirs.user_state_dir  # ~/.local/state/MyApp (Linux)
dirs.user_log_dir  # ~/.local/state/MyApp/log (Linux)
dirs.user_documents_dir  # ~/Documents
dirs.user_downloads_dir  # ~/Downloads
dirs.user_runtime_dir  # /run/user/<uid>/MyApp (Linux)

For Path objects instead of strings:

from platformdirs import PlatformDirs

dirs = PlatformDirs("MyApp", "MyCompany")
dirs.user_data_path  # pathlib.Path('~/.local/share/MyApp')
dirs.user_config_path  # pathlib.Path('~/.config/MyApp')

Convenience functions for quick access:

from platformdirs import user_data_dir, user_config_path

user_data_dir("MyApp", "MyCompany")  # returns str
user_config_path("MyApp", "MyCompany")  # returns pathlib.Path

Directory types

Application directories — scoped to your app name and version:

  • Data: Persistent application data (user_data_dir, site_data_dir)
  • Config: Configuration files and settings (user_config_dir, site_config_dir)
  • Preference: User preferences, distinct from config on macOS (user_preference_dir)
  • Cache: Cached data that can be regenerated (user_cache_dir, site_cache_dir)
  • State: Non-essential runtime state like window positions (user_state_dir, site_state_dir)
  • Logs: Log files (user_log_dir, site_log_dir)
  • Runtime: Runtime files like sockets and PIDs (user_runtime_dir, site_runtime_dir)

App dirs have both user_* (per-user, writable) and site_* (system-wide, read-only) variants where applicable.

User media directories — standard user-facing folders, not scoped to app name:

  • Documents (user_documents_dir), Downloads (user_downloads_dir)
  • Pictures (user_pictures_dir), Videos (user_videos_dir), Music (user_music_dir)
  • Desktop (user_desktop_dir), Projects (user_projects_dir)
  • Public share (user_publicshare_dir), Templates (user_templates_dir)
  • Fonts (user_fonts_dir) — user-writable font installation directory
  • Executable (user_bin_dir, site_bin_dir), Applications (user_applications_dir, site_applications_dir)

Documentation

Full documentation is available at platformdirs.readthedocs.io:

Contributions are welcome! See CONTRIBUTING.md for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

platformdirs-4.11.6.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

platformdirs-4.11.6-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file platformdirs-4.11.6.tar.gz.

File metadata

  • Download URL: platformdirs-4.11.6.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for platformdirs-4.11.6.tar.gz
Algorithm Hash digest
SHA256 1a4016e373f89f8ec458431fe0e0c5c4285858ac623f3e20efdfcbc0bd862941
MD5 8fe228ea5865dad5a1e46d500af9bf28
BLAKE2b-256 8e1d6e762a6b060e662208951aefc5c39f6a96a272c4a10c0c1f7b6113fc3c09

See more details on using hashes here.

Provenance

The following attestation bundles were made for platformdirs-4.11.6.tar.gz:

Publisher: release.yaml on tox-dev/platformdirs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file platformdirs-4.11.6-py3-none-any.whl.

File metadata

  • Download URL: platformdirs-4.11.6-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for platformdirs-4.11.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b22d992e863bc651c26b16242041c7979db6e3286e548f9a76cc91238fac599e
MD5 a3b3efe3292f689ba29e96aca968a931
BLAKE2b-256 4ed82784c6eabb991b5b7494ff9e9888c74a0a72ad613c3ec5adbfcecc0724c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for platformdirs-4.11.6-py3-none-any.whl:

Publisher: release.yaml on tox-dev/platformdirs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

4.11.7

2 files

This release

4.11.6 This release

2 files

4.11.5

2 files

4.11.4

2 files

4.11.3

2 files

4.11.2

2 files

4.11.1

2 files

4.11.0

2 files

4.10.1

2 files

4.10.0

2 files

4.9.6

2 files

4.9.4

2 files

4.9.2

2 files

4.9.1

2 files

4.9.0

2 files

4.8.0

2 files

4.7.1

2 files

4.7.0

2 files

4.6.0

2 files

4.5.1

2 files

4.5.0

2 files

4.4.0

2 files

4.3.8

2 files

4.3.7

2 files

4.3.6

2 files

4.3.5

2 files

4.3.4

2 files

4.3.3

2 files

4.3.2

2 files

4.3.1

2 files

4.3.0

2 files

4.2.2

2 files

4.2.1

2 files

4.2.0

2 files

4.1.0

2 files

4.0.0

2 files

3.11.0

2 files

3.10.0

2 files

3.9.1

2 files

3.9.0

2 files

3.8.1

2 files

3.8.0

2 files

3.7.0

2 files

3.6.0

2 files

3.5.3

2 files

3.5.2

2 files

3.5.1

2 files

3.5.0

2 files

3.4.0

2 files

3.3.0

2 files

3.2.0

2 files

3.1.1

2 files

3.1.0

2 files

3.0.0

2 files

2.6.2

2 files

2.6.1

2 files

2.6.0

2 files

2.5.4

2 files

2.5.3

2 files

2.5.2

2 files

2.5.1

2 files

2.5.0

2 files

2.4.1

2 files

2.4.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page