Install & Compatibility
Where this runs
tested against v3.13.0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.018s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.014s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
aifc
✓ import aifc
✗ from standard_aifc import aifc
The `standard-` prefix is for the package name on PyPI; the module itself imports as `aifc` because it is a direct redistribution of the standard library module.
open
✓ aifc.open('file.aiff', 'rb')
✗ from aifc import *; open('file.aiff', 'rb')
Importing `*` from `aifc` will shadow the built-in `open()` function, leading to unexpected errors, as `aifc.open` has different argument expectations.
This quickstart demonstrates how to create a simple AIFF file with dummy audio data and then read its audio parameters using the `aifc` module.
import aifc
import os
output_file = "test_audio.aiff"
# Parameters for a dummy AIFF file
nchannels = 1 # Mono
sampwidth = 2 # 2 bytes per sample (16-bit)
framerate = 44100 # 44.1 kHz
nframes = 44100 * 1 # 1 second of audio
try:
# 1. Create a dummy AIFF file
with aifc.open(output_file, 'wb') as af:
af.setnchannels(nchannels)
af.setsampwidth(sampwidth)
af.setframerate(framerate)
af.setnframes(nframes)
# Write dummy silent frames
dummy_frame = b'\x00' * (nchannels * sampwidth)
af.writeframes(dummy_frame * nframes)
print(f"Created dummy AIFF file: {output_file}")
# 2. Read parameters from the created AIFF file
with aifc.open(output_file, 'rb') as af_read:
print(f"\nReading from {output_file}:")
print(f" Channels: {af_read.getnchannels()}")
print(f" Sample width (bytes): {af_read.getsampwidth()}")
print(f" Frame rate (Hz): {af_read.getframerate()}")
print(f" Number of frames: {af_read.getnframes()}")
print(f" Compression type: {af_read.getcomptype().decode('utf-8')}")
except aifc.Error as e:
print(f"An aifc error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
finally:
# Clean up the dummy file
if os.path.exists(output_file):
os.remove(output_file)
print(f"Cleaned up {output_file}")
Debug
Known issues
breakingThe original `aifc` module was removed from the Python standard library starting with Python 3.13. Direct `import aifc` will fail in Python 3.13+ environments unless `standard-aifc` (or an equivalent) is installed.fixInstall `standard-aifc` via pip to restore the module's functionality in Python 3.13+.
affects: Python 3.13+
deprecatedThe `aifc` module was officially deprecated in the Python standard library from version 3.11, signaling its eventual removal. While `standard-aifc` provides a means to continue using it, it should be considered a legacy component.fixFor new projects, consider modern audio processing libraries (e.g., `soundfile`, `pydub`) that are actively maintained and support more formats and features. Use `standard-aifc` only for maintaining compatibility with existing codebases.
affects: Python 3.11+, removed in 3.13+
gotchaAvoid `from aifc import *`. The `aifc` module defines its own `open()` function which, if imported unqualified, will shadow the built-in `open()` function, leading to unexpected behavior and errors when trying to open non-AIFF files.fixAlways import the module as `import aifc` and access its functions via `aifc.open()`, `aifc.getnchannels()`, etc.
affects: All versions
gotchaThe `standard-aifc` package is a compatibility redistribution and is explicitly stated by its maintainers to not accept new features or anything beyond minimal compatibility work. It is not actively developed for new functionalities or extensive bug fixes.fixDo not expect new features or proactive bug fixes. For robust, long-term audio processing, evaluate actively maintained third-party libraries.
affects: All versions
gotchaThe `aifc.open()` function is strict about file modes, only accepting `'r'`, `'rb'`, `'w'`, or `'wb'`. Using other modes (e.g., `'a'`) will result in an `aifc.Error`. Additionally, the module might not correctly parse AIFF/AIFF-C files with uncommon or malformed compression type headers (e.g., 'raw ' instead of 'NONE').fixEnsure correct file modes are used when opening files. For parsing complex or non-standard AIFF/AIFF-C files, consider other libraries or pre-processing the files.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aifc'
The `aifc` module was removed from the Python standard library in Python 3.13, and existing code trying to import it will fail unless the `standard-aifc` package is installed and correctly imported.
fixFirst, install the compatibility package: `pip install standard-aifc`. Then, modify your Python code to import `standard_aifc` instead of `aifc`, often by using `import standard_aifc as aifc` for backward compatibility.
SyntaxError: invalid syntax
This error occurs when attempting to import the library using `import standard-aifc` because hyphens are not allowed in Python module names.
fixPython modules imported from PyPI packages with hyphens in their names use underscores instead. Correct the import statement to `import standard_aifc`.
ERROR: No matching distribution found for aifc
Users attempting to install the module by running `pip install aifc` will encounter this error because `aifc` was part of the standard library and is not available as a separate package on PyPI under that exact name.
fixInstall the re-packaged version from PyPI using its correct package name: `pip install standard-aifc`.
Upgrade
Version history
3.13.0latest on PyPI · released Oct 30, 2024
Audit
Dependencies
No dependency data recorded yet.