universal-startfile
raw JSON → 0.4 verified Fri May 01 auth: no python
A cross-platform replacement for os.startfile (Windows) that works on macOS and Linux by opening files with the default application. Current version 0.4, requires Python 3.9+. Releases are sporadic.
pip install universal-startfile Common errors
error ModuleNotFoundError: No module named 'universal-startfile' ↓
cause Trying to import with hyphen instead of underscore.
fix
Use
from universal_startfile import startfile (underscore). error PermissionError: [Errno 13] Permission denied ↓
cause The file exists but the user does not have execute permission for xdg-open or similar.
fix
Ensure the file is readable and that xdg-open (or equivalent) is installed and executable.
Warnings
gotcha The package name on PyPI uses hyphen (universal-startfile), but the Python module uses underscore (universal_startfile). Import as `from universal_startfile import startfile`. ↓
fix Use underscore in imports: `from universal_startfile import startfile`.
gotcha On Linux, `startfile` typically calls `xdg-open`. This may fail silently if no default application is configured or if the file type is not associated. ↓
fix Check return value (if any) or verify file associations before calling.
Imports
- startfile
from universal_startfile import startfile
Quickstart
from universal_startfile import startfile
# Open a file with the default application (cross-platform)
startfile('/path/to/file.pdf')