Registry / ai-ml / selfies

selfies

JSON →
library2.2.0pypypi✓ verified 83d ago

SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs, primarily used for molecular structures in cheminformatics and ML. Current version 2.2.0, releases every few months.

pip install selfies
INSTALL
IMPORT
SIG · SELFIES
S
selfies
ai-mlpythonv2.2.0
Install
1.5s avg
Import
51ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.052s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.050s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

encoder
from selfies import encoder
No common wrong import; just import the function.
decoder
from selfies import decoder
No common wrong import; just import the function.

Basic encode/decode a SMILES string.

from selfies import encoder, decoder smiles = "CCO" # ethanol selfies_str = encoder(smiles) print(selfies_str) # [C][C][O] smiles_back = decoder(selfies_str) print(smiles_back) # CCO
Debug
Known issues
breakingIn v2.0.0, the encoder now defaults to strict=True, raising errors for SMILES violating bond constraints. Previously, invalid SMILES were silently allowed.
fix
Use encoder(smiles, strict=False) to mimic old behavior, or ensure input SMILES are valid.
affects: >=2.0.0
deprecatedSupport for Python 3.5-3.6 dropped in v2.1.0.
fix
Upgrade to Python >=3.7.
affects: >=2.1.0
Errors
Common errors & fixes
AttributeError: module 'selfies' has no attribute 'selfies'
Wrong import style: trying to access selfies.selfies.
fix
Use from selfies import encoder, decoder directly.
RuntimeError: The input SMILES could not be parsed due to semantic constraints.
SMILES violates bond constraints (e.g., hypervalent atoms) and strict=True is default.
fix
Either fix the SMILES or pass strict=False to encoder.
TypeError: encoder() got an unexpected keyword argument 'strict'
Using version <2.0.0 where strict parameter didn't exist.
fix
Upgrade selfies: pip install --upgrade selfies
Upgrade
Version history
2.2.0latest on PyPI · released Jan 15, 2025
Audit
Dependencies
rdkitoptionalRequired for SMILES/SELFIES conversion and validity checks
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
selfies — pip install selfies · libregistry