ImportError: No module named 'newspaper3k'
Fixes the wrong-import-name error for newspaper3k. Use when you wrote `import newspaper3k` and got `ImportError: No module named 'newspaper3k'`. Not for missing newspaper (nothing installed).
There is no module called newspaper3k to import. The PyPI package is named newspaper3k but the importable module is newspaper. Change your import to from newspaper import Article (after pip install newspaper3k) and it works.
The error
ImportError: No module named 'newspaper3k'Fix it
- Fix the import line
Replace:
import newspaper3kwith:
from newspaper import ArticleExpected: the ImportError disappears.
- Make sure the package is installed
python -m pip install newspaper3k
python -c "from newspaper import Article; print('ok')"Expected: prints ok.
When this applies
- you literally wrote
import newspaper3k - the error says
No module named 'newspaper3k'(note: ImportError, not ModuleNotFoundError, on older Pythons)
When it does NOT apply
No module named 'newspaper'with the correct import means the install is missing- this is purely a naming confusion, not a broken environment
Compatibility
All newspaper3k releases. The module has always been newspaper.
Why it happens
The project renamed itself for Python 3 (newspaper3k on PyPI) but kept the original module name (newspaper) so existing code kept working. New users naturally try to import the PyPI name and hit this. It is the same class of confusion as pip install beautifulsoup4 / import bs4.
Edge cases
- If both
import newspaper3kfails ANDfrom newspaper import Articlefails with ModuleNotFoundError, you have the naming confusion plus a missing install. Fix the import line and install. - The dead
newspaperpackage on PyPI is the Python 2 original. Never install it on Python 3.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.