Install & Compatibility
Where this runs
tested against v1.4.3.5 · 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.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 65.6MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
65MB installed
● package 65MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
user_data_dir
✓ from appdirs_stubs import user_data_dir
✗ from appdirs-stubs import user_data_dir
This quickstart demonstrates how to use `appdirs` (for which `types-appdirs` provides stubs) to retrieve common application-specific directory paths for the current user and platform. It also shows how to create one of these directories, as `appdirs` only provides the path strings.
from appdirs import user_data_dir, user_config_dir, user_cache_dir
import os
appname = "MyAwesomeApp"
appauthor = "MyCompany"
# Get user-specific data directory
data_dir = user_data_dir(appname, appauthor)
print(f"User Data Directory: {data_dir}")
# Get user-specific configuration directory
config_dir = user_config_dir(appname, appauthor)
print(f"User Config Directory: {config_dir}")
# Get user-specific cache directory
cache_dir = user_cache_dir(appname, appauthor, version="1.0")
print(f"User Cache Directory (v1.0): {cache_dir}")
# Create a directory if it doesn't exist (appdirs does not create paths automatically)
os.makedirs(data_dir, exist_ok=True)
print(f"Ensured data directory exists: {data_dir}")
Debug
Known issues
deprecatedThe `types-appdirs` package is unmaintained and deprecated. The underlying `appdirs` library is also deprecated. Users should migrate to `platformdirs` which is an actively maintained fork and includes its own type information, removing the need for separate stubs.fixMigrate your application from `appdirs` to `platformdirs`. The API is largely compatible, making migration straightforward. Remove `types-appdirs` after migration.
affects: All versions
breakingFunctions like `user_data_dir`, `user_config_dir`, etc., in `appdirs` expect the application version argument to be named `version`, not `appversion`. Using `appversion` will result in a `TypeError: unexpected keyword argument`.fixCorrect the keyword argument from `appversion` to `version` when calling `appdirs` functions (e.g., `user_data_dir(appname, appauthor, version='1.0')`).
affects: appdirs < 1.4.0 (and implicitly types-appdirs for these versions), specifically pre-dating appdirs 1.4.0 where explicit appversion was added. However, the correct argument name is consistently 'version'.
gotcha`appdirs` is 'slightly opinionated' on directory names. The exact paths generated can sometimes differ from strict system conventions or other tools' interpretations, potentially adding specific suffixes to directory names.fixAlways verify the generated paths on your target operating systems. If `appdirs`'s default naming is problematic, consider examining the `platformdirs` documentation for more flexible options or implementing custom logic. You can sometimes disable opinionated behavior with `opinion=False` where available (e.g., `user_log_dir`).
affects: All versions of appdirs
gotchaOlder `appdirs` 1.x releases (e.g., 1.4.1) had specific issues with Python 3, particularly concerning Windows registry access (`winreg`) and string handling. These were addressed in subsequent minor releases.fixEnsure you are using at least `appdirs==1.4.4` for Python 3 environments. For the best compatibility and ongoing support, migrate to `platformdirs`.
affects: appdirs < 1.4.4
Upgrade
Version history
1.4.3.5latest on PyPI · released Mar 14, 2023
Audit
Dependencies
appdirsrequiredProvides runtime functionality; types-appdirs only provides type stubs.