primer3-py

raw JSON →
2.3.0 verified Fri May 01 auth: no python

Python bindings for the Primer3 primer design and analysis library. Current version 2.3.0 supports Python 3.8–3.14. Actively maintained, with occasional releases.

pip install primer3-py
error AttributeError: module 'primer3' has no attribute 'setGlobals'
cause setGlobals was removed in v1.0.0.
fix
Use primer3.set_global_flags(parameters) instead.
error TypeError: calc_tm() got an unexpected keyword argument 'mv_conc'
cause calc_tm uses keyword arguments for salt and divalent concentrations; incorrect param name.
fix
Use valid keyword arguments: mv_conc, dv_conc, dntp_conc, dna_conc.
error ValueError: Sequence 'XYZ' contains invalid characters
cause Sequence contains non-DNA letters or whitespace.
fix
Clean sequence with primer3.clean_sequence(seq) or validate manually.
breaking In v2.0.0, the output dictionary keys changed: list versions of PRIMER_PAIR, PRIMER_LEFT, PRIMER_RIGHT, PRIMER_INTERNAL were added. Code relying on old key shapes may break if not adapted.
fix Use both old and new keys or update code to use list versions.
breaking In v1.0.0, setGlobals was removed; use primer3.set_global_flags or direct parameter passing instead.
fix Replace primer3.setGlobals(...) with primer3.set_global_flags(...) or pass parameters as dict.
gotcha calc_tm accepts sequences with ambiguous bases (e.g., 'N') but may raise exceptions for invalid characters. Ensure input is valid DNA.
fix Validate or sanitize sequences before passing to calc_tm.

Calculate Tm of a DNA sequence.

import primer3

seq = 'AGCAGCGCGTATACGCGTATATACGCGATATCGCGTAGCT'
result = primer3.calc_tm(seq)
print(result)