Registry / devops / appdirs

appdirs

JSON →
library1.4.4pypypi✓ verified 25d ago

AppDirs is a small Python module (version 1.4.4) designed to determine appropriate platform-specific directories for storing user data, configuration, cache, and log files across Linux, macOS, and Windows. This project has been officially deprecated, and `platformdirs` is recommended as a more actively maintained alternative.

pip install appdirs
INSTALL
IMPORT
SIG · APPDIRS
A
appdirs
devopspythonv1.4.4
Install
1.8s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.4 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

user_data_dir
from appdirs import user_data_dir
Commonly imported functions include `user_data_dir`, `user_config_dir`, `user_cache_dir`, `site_data_dir`, `site_config_dir`, and `user_log_dir`.

This quickstart demonstrates how to use `appdirs` to retrieve common application-specific directory paths for the current user and platform. It also shows how to create one of these directories if it doesn't already exist.

from appdirs import user_data_dir, user_cache_dir, user_log_dir import os appname = "MyApplication" appauthor = "MyCompany" appversion = "1.0.0" # Get platform-specific directories data_dir = user_data_dir(appname, appauthor, appversion=appversion) cache_dir = user_cache_dir(appname, appauthor) log_dir = user_log_dir(appname, appauthor) print(f"Data directory: {data_dir}") print(f"Cache directory: {cache_dir}") print(f"Log directory: {log_dir}") # Example: Ensure the data directory exists os.makedirs(data_dir, exist_ok=True) print(f"Ensured data directory exists: {os.path.exists(data_dir)}")
Debug
Known issues
deprecatedThis project has been officially deprecated. It is recommended to use `platformdirs` (https://pypi.org/project/platformdirs/) which is an actively maintained fork with similar functionality.
fix
Migrate your application to use the `platformdirs` library. The API is largely compatible, making migration straightforward.
affects: 1.4.4 and older
gotchaAppDirs is 'slightly opinionated' on directory names. The exact paths generated can sometimes differ from strict system conventions or other tools' interpretations, potentially leading to unexpected locations. For instance, specific suffixes might be added to directory names.
fix
Always 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.
affects: All versions
gotchaWhile version 1.4.4 is generally compatible with Python 3, earlier 1.x releases (e.g., 1.4.1) had specific issues with Python 3, particularly concerning Windows registry access (`winreg`) and string handling, which were addressed in subsequent minor releases. If working with older Python 3 environments or `appdirs` versions, verify generated paths carefully.
fix
Ensure you are using at least `appdirs==1.4.4` for Python 3 environments. For the best compatibility and ongoing support, migrate to `platformdirs`.
affects: 1.0.0 - 1.4.3
breakingThe functions `user_data_dir`, `user_config_dir`, `user_cache_dir`, `user_state_dir`, `user_log_dir`, and `site_data_dir` in `appdirs` expect the version argument to be named `version`, not `appversion`. Passing `appversion` will result in a `TypeError: unexpected keyword argument`.
fix
Correct the keyword argument from `appversion` to `version` when calling `appdirs` functions. For example, change `user_data_dir(appname, appauthor, appversion=appversion)` to `user_data_dir(appname, appauthor, version=appversion)`.
affects: All versions
breakingWhen calling `user_data_dir` (and similar functions like `user_config_dir`, `user_cache_dir`, etc.), the keyword argument for specifying the application version is `version`, not `appversion`. Using `appversion` will result in a `TypeError`.
fix
Correct the keyword argument from `appversion` to `version` in your function calls. For example, use `user_data_dir(appname, appauthor, version=my_app_version)` instead of `user_data_dir(appname, appauthor, appversion=my_app_version)`.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named 'appdirs'
The 'appdirs' module is not installed in the Python environment.
fix
Install the 'appdirs' module using pip: 'pip install appdirs'.
ImportError: cannot import name 'appdirs' from 'pkg_resources.extern'
The 'appdirs' module is not available within 'pkg_resources.extern', possibly due to an outdated or incompatible version of setuptools.
fix
Update setuptools to the latest version: 'pip install --upgrade setuptools'.
ModuleNotFoundError: No module named 'appdirs'
The 'appdirs' module is not installed in the Python environment.
fix
Install the 'appdirs' module using pip: 'pip install appdirs'.
TypeError: unexpected keyword argument 'appversion'
When calling `appdirs` functions like `user_data_dir`, the argument for specifying the application version is `version`, not `appversion`.
fix
Change the keyword argument from `appversion` to `version`. For example, `appdirs.user_data_dir(appname, appauthor, version=appversion)`.
IOError: [Errno 2] No such file or directory: '.../appdirs-1.4.x.dist-info/METADATA'
This error often occurs during an upgrade or downgrade of `appdirs` via `pip`, suggesting a corrupted installation or a conflict during the uninstall/reinstall process.
fix
Try to force reinstall `appdirs`: `pip install appdirs --ignore-installed`. If the problem persists, uninstall it first `pip uninstall appdirs` and then reinstall `pip install appdirs`.
Upgrade
Version history
1.4.4latest on PyPI · released May 11, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
appdirs — pip install appdirs · libregistry