{"id":6212,"library":"pytoml","title":"pytoml","description":"pytoml is a Python library designed for parsing and writing TOML (Tom's Obvious, Minimal Language) files. It specifically targets version 0.4.0 of the TOML specification. The library provides an interface similar to Python's standard `json` module, offering `load`, `loads`, `dump`, and `dumps` functions. The project is no longer actively maintained, with its last release (0.1.21) in July 2019.","status":"deprecated","version":"0.1.21","language":"python","source_language":"en","source_url":"https://github.com/avakar/pytoml","tags":["TOML","configuration","parser","deprecated"],"install":[{"cmd":"pip install pytoml","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The common and recommended practice is to import `pytoml` as `toml` to align with other TOML libraries and the common CLI tool name.","wrong":"import pytoml","symbol":"load, loads, dump, dumps","correct":"import pytoml as toml"}],"quickstart":{"code":"import pytoml as toml\nimport io\n\n# Loading from a string\ntoml_string = 'title = \"My TOML Document\"\\nowner = { name = \"John Doe\" }'\ndata_from_string = toml.loads(toml_string)\nprint(f\"From string: {data_from_string}\")\n\n# Loading from a file-like object (e.g., a file)\n# Using io.BytesIO to simulate reading a file in binary mode ('rb')\ntoml_file_content = b'[database]\\nserver = \"192.168.1.1\"\\nports = [8001, 8002, 8003]'\nfile_like_object = io.BytesIO(toml_file_content)\ndata_from_file = toml.load(file_like_object)\nprint(f\"From file-like object: {data_from_file}\")\n\n# Dumping to a string\ndict_to_dump = {'server': '10.0.0.1', 'connection_max': 5000}\ndumped_string = toml.dumps(dict_to_dump)\nprint(f\"Dumped TOML string:\\n{dumped_string}\")","lang":"python","description":"Demonstrates loading TOML data from a string and a file-like object, and dumping a Python dictionary to a TOML string. Note that `load` expects a binary-read file object (e.g., opened with 'rb')."},"warnings":[{"fix":"Migrate to actively maintained TOML parsers such as `tomli` (standard library in Python 3.11+, read-only) or `tomlkit` (for full round-trip preservation and writing).","message":"The `pytoml` library is officially deprecated and no longer actively maintained. Its GitHub README explicitly advises users to consider alternatives. This means it will not receive updates for new Python versions, TOML specification changes, or security fixes.","severity":"breaking","affected_versions":"All versions, especially 0.1.21 and older"},{"fix":"Switch to a TOML 1.0.0 compliant parser. `tomli` (for Python 3.6-3.10 and earlier 3.11+, read-only) and `tomlkit` (for full TOML 1.0.0 support, including preserving formatting) are recommended alternatives.","message":"pytoml only supports TOML specification version 0.4.0. The current stable TOML specification is 1.0.0. Using `pytoml` with modern `pyproject.toml` files or other TOML 1.0.0 compliant configurations will likely lead to parsing errors or incorrect data interpretation due to syntax changes between versions.","severity":"breaking","affected_versions":"All versions, as it's an inherent design limitation."},{"fix":"Always open TOML files for reading with `with open('your_file.toml', 'rb') as f: data = toml.load(f)`.","message":"When using `toml.load()`, the file object must be opened in binary read mode (`'rb'`). Passing a text-mode file object (`'r'`) will result in a `TypeError` or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.1.21':58 '0.4.0':23 '2019':61 'activ':52 'configur':63 'deprec':65 'design':7 'dump':43,45 'file':18 'function':46 'interfac':32 'json':38 'juli':60 'languag':17 'last':56 'librari':6,29 'load':41,42 'longer':51 'maintain':53 'minim':16 'modul':39 'obvious':15 'offer':40 'pars':9 'parser':64 'project':48 'provid':30 'python':5,35 'pytoml':1,2 'releas':57 'similar':33 'specif':20,27 'standard':37 'target':21 'tom':13 'toml':12,26,62 'version':22 'write':11","created_at":"2026-04-14T18:46:50.559526+00:00","updated_at":"2026-04-16T20:32:31.134386+00:00","problems":[{"fix":"pip install pytoml","cause":"The 'pytoml' library is not installed in the current Python environment or the environment is not active.","error":"ModuleNotFoundError: No module named 'pytoml'"},{"fix":"Ensure the input is a string. If reading from a file, open it in text mode (e.g., `open('file.toml', 'r', encoding='utf-8')`) or decode the bytes if already read (e.g., `data.decode('utf-8')`).","cause":"The `pytoml.loads()` function (or similar) was passed a bytes-like object (e.g., from a file opened in binary mode) when it expects a string.","error":"TypeError: a string-like object is required, not 'bytes'"},{"fix":"Review and correct the TOML syntax in the input data to ensure it is valid according to the TOML 0.4.0 specification.","cause":"The input TOML string or file contains syntax errors or does not conform to the TOML 0.4.0 specification that `pytoml` implements.","error":"pytoml.tomllang.TomlParsingError"},{"fix":"This is a warning from the library itself due to its age and not an error that stops execution. No direct fix for the user's code, but you can ignore the warning or consider migrating to a more actively maintained TOML library if it's bothersome.","cause":"This warning occurs in newer Python versions (3.10+) because `pytoml` internally uses `distutils.version`, which has been deprecated.","error":"DeprecationWarning: distutils Version classes are deprecated"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.21","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/avakar/pytoml","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytoml/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}