安装Scrapy时遇Command "python setup.py egg_info"错误,求解决方案
Hey there, I’ve dealt with this exact "python setup.py egg_info" error for cffi when installing Scrapy on Windows before—let’s walk through some targeted fixes that might work even after trying the standard Stack Overflow solutions:
Install the required C build tools
Windows doesn’t come with a C compiler by default, which cffi needs to build from source. Grab the Microsoft Visual C++ Build Tools:- Download the installer from the official Microsoft site (just search for "Visual Studio Build Tools" and pick the 2019 or 2022 version matching your Python’s architecture).
- When installing, make sure to check the Desktop development with C++ workload (it includes all necessary compilers and libraries).
- Restart your command prompt or terminal after installation, then try installing Scrapy again with
pip install scrapy.
Use pre-compiled wheel packages for cffi
Instead of building cffi from source, force pip to use pre-built binaries:- First install the wheel package if you haven’t:
pip install wheel - Then install cffi with binary-only mode:
pip install cffi --only-binary :all: - Once cffi installs successfully, run
pip install scrapyagain.
- First install the wheel package if you haven’t:
Purge your pip cache
Corrupted cached packages can cause weird install failures. Clear the cache with:pip cache purgeThen retry the Scrapy install command.
Check Python version compatibility
Make sure your Python version is fully supported by the latest Scrapy release. For example, Scrapy 2.11.x supports Python 3.8–3.11. If you’re using Python 3.12+, you might hit compatibility issues—try downgrading to a supported version (use a virtual environment to avoid messing up your main setup) or wait for an updated Scrapy release.Try installing via Conda (if you use it)
Conda handles dependency compilation automatically, which can bypass this cffi build issue entirely. If you have Conda installed, run:conda install -c conda-forge scrapy
Give these steps a shot one by one—usually either the build tools or pre-compiled wheels fix this for Windows users.
内容的提问来源于stack exchange,提问作者Eternal

