Python sentiment analysis libraries

Updated Nov 2026

Python sentiment analysis libraries score text as positive, negative, or neutral. A lexicon-based scorer applies a fixed dictionary and rules rather than a trained neural model. These libraries let support tools, social media monitors, and AI agents measure how people feel about a product.

Popularity

Transformers has the most monthly downloads in this comparison, at 119.8M, a count that covers every model task in the library.

LibraryMonthly downloadsStarsLast releaseLicense
Transformers
119.8M
168.9KNov 2026Apache-2.0
NLTK
48.3M
14.8KOct 2026Apache-2.0
TextBlob
3.2M
9.6KJul 2026MIT
VADER
1.2M
5.1KMay 2020MIT
Stanza
1.0M
7.9KNov 2026Apache-2.0
Polyglot
87.4K
2.4KJul 2016GPLv3
Flair
65.0K
14.4KFeb 2025MIT
pysentimiento
6.9K
665Mar 2024Custom non-commercial/research-only
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Runs pretrained sentiment classifiers and supports fine-tuning on labeled datasets.

Downloads / mo
119.8M
Stars
168.9K
Last release
5.23.0
License
Apache-2.0

Strengths

  • Fine-tunes for a specific classification task. Adapt a pretrained model using labeled examples from the target task.
  • Batches sentiment inference. Pass lists, datasets, or generators to a pipeline with batching.

Limitations

  • Long inputs need length handling. Truncate or split inputs that exceed the model’s accepted sequence length.
  • Large batches can exhaust memory. Reduce batch size when inference runs out of memory.

Quickstart

From text_classification.py
$ pip install "transformers[torch]"
from transformers import pipeline
classifier = pipeline(model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
classifier("This movie is disgustingly good !")

Transformers examples

From open-source projects on GitHub

Provides a natural language toolkit.

Downloads / mo
48.3M
Stars
14.8K
Last release
3.10.4
License
Apache-2.0

Quickstart

From sentiment.doctest
$ pip install nltk
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
nltk.download("vader_lexicon")
sid = SentimentIntensityAnalyzer()
sid.polarity_scores("VADER is smart, handsome, and funny.")

NLTK examples

From open-source projects on GitHub

Returns polarity and subjectivity scores and supports custom text classifiers.

Downloads / mo
3.2M
Stars
9.6K
Last release
0.20.1
License
MIT

Strengths

  • Separates polarity and subjectivity. Read sentiment direction and subjectivity as separate values.
  • Trains custom text classifiers. Train a classifier on custom labeled text examples.

Limitations

  • Analyzer choice changes returned values. NaiveBayesAnalyzer returns class probabilities instead of polarity and subjectivity.
  • Optional analyzer uses movie reviews. The built-in NaiveBayesAnalyzer is trained on a movie-review corpus.

Quickstart

From classifiers.html
$ pip install -U textblob
from textblob import TextBlob
testimonial = TextBlob("Textblob is amazingly simple to use. What great fun!")
testimonial.sentiment

TextBlob examples

From open-source projects on GitHub

Scores sentiment with a lexicon and rules designed for social-media language.

Downloads / mo
1.2M
Stars
5.1K
Last release
3.3.2
License
MIT

Strengths

  • Handles informal text signals. Rules account for punctuation, emphasis, negation, and contrastive conjunctions.
  • Returns a composite sentiment score. Use compound for the normalized score after lexical and rule adjustments.

Limitations

  • Non-English examples use translation. Translate non-English inputs separately; VADER does not provide its own translator.
  • Compound and category scores differ. Use compound for overall sentiment; category ratios omit intensity rules.

Quickstart

From README.rst
$ pip install vaderSentiment
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
analyzer.polarity_scores("VADER is smart, handsome, and funny.")

VADER examples

From open-source projects on GitHub

Processes text in many human languages.

Downloads / mo
1.0M
Stars
7.9K
Last release
1.15.1
License
Apache-2.0

Quickstart

From sentiment.md
$ pip install stanza
import stanza
nlp = stanza.Pipeline(lang='en', processors='tokenize,sentiment')
doc = nlp('I hate that they banned Mox Opal')

Runs a multilingual natural language pipeline.

Downloads / mo
87.4K
Stars
2.4K
Last release
16.7.4
License
GPLv3

Quickstart

From Sentiment.ipynb
$ pip install polyglot
from polyglot.text import Text
text = Text("The movie was really good.")
text.words[4].polarity

Loads sentiment models and trains text classifiers with configurable embeddings.

Downloads / mo
65.0K
Stars
14.4K
Last release
0.15.1
License
MIT

Strengths

  • Trains custom sentiment models. Train a text classifier with a custom corpus and label dictionary.
  • Supports minibatched predictions. Pass data points to predict() and configure mini_batch_size.

Limitations

  • Standard sentiment model targets English. The standard sentiment checkpoint classifies English movie and product reviews.
  • Standard sentiment labels are binary. The standard sentiment models predict positive or negative, without a neutral label.

Quickstart

From README.md
$ pip install flair
from flair.data import Sentence
from flair.nn import Classifier

# make a sentence
sentence = Sentence('I love Berlin .')

# load the NER tagger
tagger = Classifier.load('sentiment')

# run NER over sentence
tagger.predict(sentence)

# print the sentence with all annotations
print(sentence)

Flair examples

From open-source projects on GitHub
def score(self, text: str) -> int:
    from flair.data import Sentence
    doc = Sentence(text)
    self.model.predict(doc)
    pred = int(doc.labels[0].value)
    return pred

pysentimiento

Runs Transformer models for social NLP tasks.

Downloads / mo
6.9K
Stars
665
Last release
0.7.3
License
Custom non-commercial/research-only

Quickstart

From README.md
$ pip install pysentimiento
from pysentimiento import create_analyzer
analyzer = create_analyzer(task="sentiment", lang="es")
analyzer.predict("Qué gran jugador es Messi")

FAQ

Transformers suits applications that run or fine-tune pretrained sentiment classifiers. VADER suits social media text scored by a lexicon and rules. TextBlob suits code that needs separate polarity and subjectivity scores.

VADER is a lexicon and rule-based sentiment analysis tool attuned to sentiments expressed in social media. It returns a composite score alongside its category scores.

TextBlob returns separate polarity and subjectivity scores and trains custom text classifiers. VADER scores informal social media text with a lexicon and rules.

Flair loads sentiment models and trains text classifiers with configurable embeddings. Its standard sentiment model targets English with binary labels.

For coding agents

Found your sentiment analysis library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official