ImportError: cannot import name 'FeedParserDict' from 'feedparser'
Fixes the FeedParserDict import failing because a stale vendored feedparser shadows the real one. Use when `from feedparser import FeedParserDict` raises ImportError naming FeedParserDict. Not for `No module named 'feedparser'`.
The feedparser Python found is an ancient vendored copy (often a lib/feedparser folder inside an old app) that predates the FeedParserDict class. Find the stale copy with python -c "import feedparser; print(feedparser.__file__)", delete or replace it, and make sure feedparser 6.x is installed. The import works once the real package is the one being found.
The error
ImportError: cannot import name 'FeedParserDict' from 'feedparser'Fix it
- Find which feedparser is being imported
python -c "import feedparser; print(feedparser.__file__)"Expected: a site-packages path. If it prints a path inside your project (like lib/feedparser/__init__.py), that vendored copy is shadowing the real install.
- Remove or replace the stale copy
Delete the vendored feedparser folder from the project, or replace it with a current copy. Vendored copies from the 5.x era have no FeedParserDict class at all.
- Install the real feedparser 6.x
python -m pip install -U feedparserExpected: Successfully installed feedparser-6....
- Confirm
python -c "from feedparser import FeedParserDict; print('ok')"Expected: prints ok.
When this applies
from feedparser import FeedParserDictraises ImportError naming FeedParserDict- the app vendors its own
lib/dependencies (old SickChill-style layout) - feedparser imports fine but the class is missing
When it does NOT apply
No module named 'feedparser'means nothing is installedNo module named 'sgmllib'means the installed copy is 5.x on Python 3 (upgrade instead)
Compatibility
FeedParserDict exists in feedparser 5.x installed from PyPI and all of 6.x. The failure means the found copy is older than that or a partial vendor.
Why it happens
Old applications vendored feedparser by copying its source into their own tree. Those copies froze at whatever version was current years ago, and some predate the FeedParserDict class. Because the project directory beats site-packages in import order, the fossil wins over any modern feedparser you pip-install, and the class lookup fails.
Edge cases
- After deleting the vendored folder, clear
__pycache__or the stale .pyc can still shadow. - If other code in the app relied on the vendored copy's quirks, run its test suite after switching to 6.x. The 5-to-6 upgrade changed some parsing behaviors.
- Namespace confusion: a folder named
feedparsercontaining only some of the modules produces exactly this half-broken state.