Registry / data / newick

newick

JSON →
library1.11.0pypypi✓ verified 90d ago

A Python module to read and write the Newick format, commonly used for phylogenetic trees. Current version: 1.11.0. Release cadence is irregular; maintained on GitHub.

pip install newick
INSTALL
IMPORT
SIG · NEWICK
N
newick
datapythonv1.11.0
Install
1.5s avg
Import
51ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.11.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
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.056s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.046s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

loads
✓ from newick import loads
Standard import for parsing Newick strings.
dumps
✓ from newick import dumps
Standard import for writing Newick strings.
load
✓ from newick import load
Load Newick from a file.
dump
✓ from newick import dump
Write Newick to a file.

Parses a Newick string into a tree of Node objects and serializes back.

from newick import loads, dumps # Load a Newick string tree = loads('(A:0.1,B:0.2,(C:0.3,D:0.4):0.5);') # tree is a list of Node objects (rooted at index 0) node = tree[0] print(node.name) # None (internal node) print(node.descendants) # list of Nodes print(node.length) # None (for root) # Modify the tree and dump back to string node.name = 'root' newick_str = dumps(node) print(newick_str)
Debug
Known issues
gotchaloads() returns a list of Node objects, not a single Node. For a tree with one root, access index 0.
fix
tree = loads(newick_str)[0]
affects: all
gotchaNode names can include special characters like ':' or ',' but must be quoted. The library may fail to parse if names contain unescaped special characters.
fix
Ensure node names are properly escaped or quoted in the Newick string.
affects: all
deprecatedThe 'read' and 'write' functions (from newick import read, write) are deprecated as of v1.9.0. Use load/dump instead.
fix
Use load() for reading files and dump() for writing.
affects: >=1.9.0
breakingIn v1.9.0, the internal Node class changed: removed 'ancestor' attribute and added 'parent'. Code relying on 'node.ancestor' will break.
fix
Use 'node.parent' instead of 'node.ancestor'.
affects: >=1.9.0
Errors
Common errors & fixes
AttributeError: module 'newick' has no attribute 'loads'
Installed old version (<1.0) that lacked loads/dumps; or named conflict with other module.
fix
Upgrade to latest: pip install --upgrade newick. Check import: from newick import loads
IndexError: list index out of range when accessing tree[0]
The Newick string is empty or malformed (e.g., missing semicolon). loads() returns empty list.
fix
Ensure the Newick string is valid and ends with ';'. Check: tree = loads(newick_str); assert tree
TypeError: expects a string or file-like object
Passed a Node object to load() instead of a file path or string.
fix
Use dumps(node) to serialize, not load(). load() is for reading from file.
ValueError: Node name contains illegal characters
Node name includes unescaped newick special characters like '(', ')', ':', ',', ';'.
fix
Quote the name using single quotes in the Newick string, e.g., "'My:Node'".
Upgrade
Version history
1.11.0latest on PyPI · released Jan 14, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Anthropic
1
Resources
newick — pip install newick · libregistry