Running into the ModuleNotFoundError: No module named 'cloudscraper' error? You're definitely not alone. It’s one of the more common headaches Python developers face—especially when working on web scraping projects that rely on bypassing Cloudflare protections.
Cloudscraper is a go-to Python library for navigating through Cloudflare’s anti-bot defenses. So when your script suddenly throws this error, it can feel like everything grinds to a halt. The good news? It’s almost always fixable—and usually within a few minutes if you follow the right steps.
In this guide, we’ll walk you through exactly how to solve this error in four straightforward steps. By the end, you’ll have cloudscraper installed, configured, and working like it should—so you can get back to scraping.
Why You Can Trust This Solution
This isn't just a random fix found on a forum—we’ve helped dozens of developers work through this exact problem. After seeing the same patterns and missteps again and again, we’ve refined a clear, reliable path to get cloudscraper up and running. These steps work across different operating systems and Python environments, and they’ve stood the test of real-world troubleshooting.
Step 1: Verify Python Version and Environment
Before you start reinstalling anything, take a step back and make sure your Python setup is actually configured correctly. It’s a common oversight—but it’s often the root cause of the issue.
Check Your Python Version
Start by opening your terminal or command prompt and running:
python --version
Or, if you're using Python 3:
python3 --version
Make sure you're running Python 3.6 or higher—cloudscraper works best with those versions.
Confirm Your Environment Is Activated
If you're using a virtual environment (which you absolutely should for any Python project), make sure it's active. If not, you might be installing packages in the wrong place entirely.
For standard virtual environments:
On Windows:
venv\Scripts\activate
On macOS/Linux:
source venv/bin/activate
For Conda environments:
conda activate your_environment_name
When activated, your terminal will usually show the environment name in parentheses at the beginning of the prompt. If you don't see it—you're probably not in the right environment.
Step 2: Install Cloudscraper Correctly
Once you’re confident your environment is set, it’s time to install cloudscraper properly—without any lingering conflicts or confusion.
Uninstall Previous Versions First
To be safe, remove any potentially corrupted or outdated versions:
pip uninstall cloudscraper
Reinstall Using Pip
Then do a clean install:
pip install cloudscraper
Or, if you’re using Python 3:
pip3 install cloudscraper
Confirm It’s Installed
You can double-check with:
pip list | grep cloudscraper
Or on Windows:
pip list | findstr cloudscraper
If everything went as expected, you should see cloudscraper and its version number listed.
Step 3: Install Required Dependencies
Cloudscraper isn’t a standalone solution—it relies on a few other packages to do its job. If any of these are missing or mismatched, things can break fast.
Core Dependencies
Here’s the quick command to install what cloudscraper needs to run smoothly:
pip install requests>=2.9.2 requests-toolbelt>=0.9.1 js2py>=0.67
These ensure the library has everything it needs to handle requests and interpret JavaScript challenges.
JavaScript Interpreter (When Needed)
Some Cloudflare challenges are more complex and require a dedicated JavaScript engine. While cloudscraper tries to solve most issues natively, tough ones may need external help.
Here are your options:
- Node.js (your best bet for tougher challenges)
- Download from Node.js official site
- Confirm it’s installed:
node --version
- ChakraCore:
- Download the binary from ChakraCore GitHub
- Add it to your system’s PATH
- V8 (advanced users):
- Install via:
pip install v8eval
- Install via:
If you're using one of these interpreters, you can tell cloudscraper explicitly which one to use:
import cloudscraper
scraper = cloudscraper.create_scraper(interpreter='nodejs')
Step 4: Test Your Installation
Now for the moment of truth—does it actually work?
Start by running this simple test script. Save the code below into a file named test_cloudscraper.py
:
import cloudscraper
# Create a scraper instance
scraper = cloudscraper.create_scraper()
# Make a simple request to a test site
try:
response = scraper.get('https://httpbin.org/ip')
print("Success! Response:", response.text)
except Exception as e:
print("Error:", e)
Then run it:
python test_cloudscraper.py
If all goes well, you’ll see your IP address returned in the response. That means cloudscraper is installed and working.
Try a Real-World Test
Next, you can try it on a site that actually uses Cloudflare (as long as you have permission to access it). Expect a few seconds of delay while cloudscraper does its magic:
import cloudscraper
# Create a scraper with browser emulation options
scraper = cloudscraper.create_scraper(
browser={
'browser': 'chrome',
'platform': 'windows',
'mobile': False
}
)
try:
# Replace with a Cloudflare-protected site you have permission to access
response = scraper.get('https://example.com')
print("Status code:", response.status_code)
print("Success!")
except Exception as e:
print("Error:", e)
Common Pitfalls to Avoid
Even with everything done right, small missteps can still trip you up. Here’s what to watch out for:
Multiple Python Versions
If your system has multiple versions of Python, make sure you’re using the one where cloudscraper was installed. You can do this with:
python3.8 -m pip install cloudscraper
Permission Problems
Sometimes installs fail silently due to permission restrictions.
On Windows: Run your terminal as Administrator
On macOS/Linux: Use sudo
:
sudo pip install cloudscraper
Or install just for your user:
pip install --user cloudscraper
Forgot to Activate Virtual Environment
This is probably the most common one. If you're installing cloudscraper globally but running your script inside a virtual environment, the module won't be found. Always activate the right environment before installing or running your script.
Troubleshooting Additional Issues
Still Seeing ImportError
?
Try a few of these:
- Look for naming conflicts:
Make sure you don’t have a file namedcloudscraper.py
in your project—that’ll interfere with the import.
Force a clean reinstall:
pip install --force-reinstall cloudscraper
Check Python's path:
python -c "import sys; print(sys.path)"
Cloudflare Challenge Failures
If you’re seeing something like:
cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 challenge
That means the version of Cloudflare protection is newer than what your current cloudscraper can handle.
Here’s what you can try:
- Consider a more robust tool like Selenium or Playwright if the protection is too advanced.
Change the browser settings in your scraper:
scraper = cloudscraper.create_scraper(
browser={'browser': 'firefox', 'platform': 'windows'}
)
Update cloudscraper:
pip install --upgrade cloudscraper
Final Thoughts
Getting hit with a "No module named 'cloudscraper'" error can feel like a blocker, but in reality, it’s almost always a sign of a misconfigured environment or a missing dependency. By methodically following the steps in this guide, you’ll get cloudscraper running correctly—and avoid wasting hours in the process.
That said, always make sure your scraping practices align with the terms of service of the sites you’re targeting. Tools like cloudscraper are powerful—but they should be used responsibly.