Registry / serialization / parso
library0.8.7pypypi✓ verified 24d ago

Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions. It is currently at version 0.8.6, released on February 9, 2026, and follows a regular release cadence with updates approximately every 6 months.

pip install parso
INSTALL
IMPORT
SIG · PARSO
P
parso
serializationpythonv0.8.7
Install
1.7s avg
Import
108ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.7 · 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.118s · 18.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.098s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

parse
from parso import parse
The 'parse' function is the main entry point for parsing Python code.

This example demonstrates how to parse a simple Python function definition and call using Parso.

import parso code = 'def greet(name):\n return f"Hello, {name}!"\n\ngreet('World')' # Parse the code module = parso.parse(code, version='3.9') # Access the root node root_node = module.get_root_node() # Print the parsed code print(root_node.get_code())
Debug
Known issues
breakingParso dropped support for Python 2.7, 3.4, and 3.5 in version 0.8.0.
fix
Upgrade to a supported Python version (3.6 or later).
affects: 0.8.0
deprecatedThe 'lib2to3' module is deprecated since Python 3.10 and may be removed in future versions. Parso is a recommended alternative.
fix
Use Parso for parsing tasks instead of 'lib2to3'.
affects: 3.10+
gotchaA `SyntaxError: invalid syntax` occurred because a single-quoted string literal (`'...'`) contained an unescaped single quote, prematurely terminating the string and leading to invalid syntax at the subsequent characters.
fix
To resolve, escape the internal single quotes (e.g., `\'World\'`) or enclose the entire string in double quotes (`"..."`) or triple quotes (`'''...'''`) to allow internal single quotes without escaping.
affects: All
breakingA `SyntaxError` occurred in the test script due to an unescaped quote within a string literal used for code generation, preventing the script from running. This is a fundamental Python syntax issue with string definition.
fix
Ensure string literals in test scripts are correctly escaped (e.g., `\'World\'`) or use triple quotes (e.g., `'''... 'World' ...'''`) to define multi-line code snippets that contain single or double quotes.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'parso'
The 'parso' library has not been installed in the Python environment where the code is being executed.
fix
Install the 'parso' package using pip: `pip install parso`
SyntaxError: invalid syntax
This error message is typically returned by `parso` when the code it attempts to parse contains actual Python syntax errors, or when `parso` is used with a Python version that doesn't match the syntax of the provided code.
fix
Correct the syntax of the Python code being parsed. If the code uses modern Python features, ensure your installed 'parso' version is up-to-date (`pip install --upgrade parso`) and explicitly specify the Python version using the `version` parameter in `parso.parse()` or `parso.load_grammar()` (e.g., `parso.parse('code', version='3.9')`).
ImportError: cannot import name 'Parser'
Users attempting to directly import a class named 'Parser' from the 'parso' package or its submodules, which is not part of the public API or has a different internal name.
fix
Instead of directly importing `Parser`, use the public API functions like `parso.parse()` for simple parsing or `parso.load_grammar().parse()` for more controlled parsing with a specific grammar.
KeyError: ReservedString(})
This error can occur when `parso` encounters complex or malformed string literals, especially f-strings or raw strings with unescaped curly braces, that it struggles to tokenize or parse correctly.
fix
Review the string literal in the code for proper escaping of special characters like curly braces in f-strings or backslashes in raw strings. Ensure the string is well-formed according to Python's grammar. Updating 'parso' to the latest version might also resolve issues with newer string syntaxes.
Upgrade
Version history
0.8.7latest on PyPI · released May 1, 2026
Audit
Dependencies
typingrequiredRequired for type annotations
Agent activity
9 hits · last 30 days
node
8
Resources
parso — pip install parso · libregistry