langchain-ai/langgraph · error · ImportError
Pycryptodome is not installed. Please install it with `pip…
Error message
Pycryptodome is not installed. Please install it with `pip install pycryptodome`.
What it means
Optional-dependency guard in EncryptedSerializer.from_pycryptodome_aes: the classmethod tries `from Crypto.Cipher import AES` to build an AES cipher; the ImportError is intercepted and re-raised as this actionable ImportError. It fires only because the pycryptodome distribution is absent from the environment — the input at fault is the environment, not any argument.
Solutions
- Install the optional dependency: pip install pycryptodome
- Or add langgraph-checkpoint[encryption] if such an extra is declared in your install
- Verify with `python -c "from Crypto.Cipher import AES"` after installing
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/checkpoint/langgraph/checkpoint/serde/encrypted.py:46 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/bf89a44eb6fadee6.
Report an issue: GitHub.
Appendix: source
Thrown at libs/checkpoint/langgraph/checkpoint/serde/encrypted.py:46
# unencrypted data
if "+" not in enc_cipher:
return self.serde.loads_typed(data)
# extract cipher name
typ, ciphername = enc_cipher.split("+", 1)
# decrypt data
decrypted_data = self.cipher.decrypt(ciphername, ciphertext)
# deserialize data
return self.serde.loads_typed((typ, decrypted_data))
@classmethod
def from_pycryptodome_aes(
cls, serde: SerializerProtocol = JsonPlusSerializer(), **kwargs: Any
) -> "EncryptedSerializer":
"""Create an `EncryptedSerializer` using AES encryption."""
try:
from Crypto.Cipher import AES
except ImportError:
raise ImportError(
"Pycryptodome is not installed. Please install it with `pip install pycryptodome`."
) from None
# check if AES key is provided
if "key" in kwargs:
key: bytes = kwargs.pop("key")
else:
key_str = os.getenv("LANGGRAPH_AES_KEY")
if key_str is None:
raise ValueError("LANGGRAPH_AES_KEY environment variable is not set.")
key = key_str.encode()
if len(key) not in (16, 24, 32):
raise ValueError("LANGGRAPH_AES_KEY must be 16, 24, or 32 bytes long.")
# set default mode to EAX if not provided
if kwargs.get("mode") is None:
kwargs["mode"] = AES.MODE_EAX
View on GitHub (pinned to 38031739e5)