SMTPLIB
pip install smtplib fails — smtplib is in Python's standard library with no PyPI package. Use import smtplib. If that fails, a local file is shadowing it.
Updated Jul 1, 2026
The short answer
pip install smtplib fails ("No matching distribution found for smtplib") because smtplib is part of Python's standard library, not a PyPI package — there is nothing to install. Just remove the install command and import smtplib directly. If the import itself errors, you almost certainly have a local file shadowing a stdlib module (commonly email.py or smtplib.py); rename it and delete the stale .pyc.
pip install smtplib not working?Because there is nothing to install. smtplib is part of the Python standard library — it ships with every Python interpreter (CPython 2.3+ and all of Python 3). It is not published on PyPI, so pip has no distribution to download. That is exactly why you see:
ERROR: Could not find a version that satisfies the requirement smtplib(from versions: none)ERROR: No matching distribution found for smtplib
This is the same reason pip install json, pip install os, or pip install collections all fail — those are built-in modules, not packages.
You don't install it — you just import it. Delete the pip install smtplib line (and drop it from any requirements.txt), then use it directly:
import smtplibwith smtplib.SMTP("smtp.example.com", 587) as server:server.starttls()server.login("user@example.com", "app-password")server.sendmail("user@example.com", "to@example.com", "Subject: Hi\n\nBody")
To confirm it's already available, run:
python -c "import smtplib; print(smtplib.__file__)"
That prints the path to smtplib.py inside your Python installation — proof it's present without pip.
secure-smtplib package?Some older answers tell you to run pip install secure-smtplib. Skip this on Python 3. secure-smtplib is a Python 2-only backport that added SMTP_SSL and TLS certificate validation to Python 2's smtplib. Python 3's standard smtplib already includes SMTP_SSL and starttls() natively, so the backport adds nothing and importing it does not give you a smtplib module. Installing it will not fix this error and only adds an unmaintained dependency (no release since 2015).
import smtplib itself fails?If pip was never the problem and import smtplib raises ImportError/ModuleNotFoundError or an odd AttributeError, you almost certainly have a local file shadowing a standard-library module. The two usual culprits:
smtplib.py in your project — Python imports your file instead of the stdlib one.email.py (or an email/ folder) — smtplib imports the stdlib email package internally, so shadowing it breaks smtplib too.Fix it:
my_email.py)..pyc and any __pycache__/email.*.pyc / smtplib.*.pyc.import smtplib.With Courier
References
FAQ
Because smtplib is a Python standard-library module, not a PyPI package. It ships with every Python install, so pip has no distribution to download and returns 'No matching distribution found for smtplib.' Remove the install command and just use import smtplib.
One API, every provider
Courier connects to your email, SMS, and push providers, handles retries and failover, and surfaces delivery errors in plain language.
Last reviewed Jul 1, 2026. Courier is not affiliated with third-party providers; error behavior may vary by implementation.
© 2026 Courier. All rights reserved.