ModuleNotFoundError: No module named 'scrapy'
Fixes the plain missing-module error for Scrapy. Use when `import scrapy` or the `scrapy` command fails with ModuleNotFoundError naming scrapy. Not for missing twisted or win32api (Scrapy is installed but a dependency is not).
Scrapy is not installed in the Python that is running. Run python -m pip install scrapy and both the import and the scrapy CLI start working. If it still fails, your pip and your python belong to different installations, so always spell it python -m pip.
The error
ModuleNotFoundError: No module named 'scrapy'Fix it
- Install Scrapy with the running interpreter's pip
python -m pip install scrapyExpected: Successfully installed scrapy-... plus its dependencies.
- Confirm the import and the CLI
python -c "import scrapy; print(scrapy.__version__)"
scrapy versionExpected: both print a version like 2.11.0.
- If the import still fails, find the interpreter mismatch
python --version
pip --versionExpected: the paths in the two outputs match. If they do not, the install went to a different Python. Redo step 1 exactly as written.
When this applies
import scrapyorscrapy crawl/scrapy versionfails namingscrapy- a new machine, container, or venv
- the tutorial said
pip install scrapybut your shell has several Pythons
When it does NOT apply
No module named 'twisted'means Scrapy is there but Twisted is notNo module named 'win32api'is the Windows pywin32 gap- an ImportError inside scrapy's own modules is a broken install, reinstall with --force-reinstall
Compatibility
All Scrapy 2.x. Needs Python 3.8+. On Windows the installer also wants pywin32 (see the win32api skill).
Why it happens
Nothing more exotic than a missing install, but Scrapy is big enough that people often install it into one Python (say the system one) while their project runs under another (a venv, conda env, or IDE-managed interpreter). python -m pip removes the ambiguity by tying the installer to the interpreter.
Edge cases
- Portia and other Scrapy-based tools hit this when their bundled env is not activated. Activate the env first, then check.
- On Debian/Ubuntu,
pip install scrapymay try building Twisted from source on old Pythons. Prefer a newer Python with wheels. scrapycommand not found after install means the Scripts/bin dir is not on PATH.python -m scrapyworks as a fallback.
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.