How to Prevent Python Package Test Data from Appearing in Windows Search
Problem: Windows Search Suggested “YouPorn” When I Typed “YouTube”
I was demoing my machine to a colleague. I hit the Windows key and typed “YouTube” to open the site.
Windows Search suggested:
YouTubeYouPorn (C:\anaconda3\Lib\site-packages\protego\tests\www.youporn.com)My colleague saw it. I wanted to die.
The file wasn’t porn. It was a test fixture from the Protego Python library—a robots.txt parsing tool that uses real domain names for testing.
But Windows Search didn’t care. It indexed everything in my user profile, including:
C:\Users\me\AppData\Local\Continuum\anaconda3\pkgs\protego\info\test\tests\test_data\www.youporn.comC:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\protego\tests\www.youporn.comC:\Users\me\.conda\envs\research\Lib\site-packages\protego\tests\www.youporn.comEvery environment I’d ever created was indexed.
I needed to fix this immediately.
Why Windows Search Indexes Python Packages
Windows Search has a simple default behavior:
Index everything in user profile directories.
This includes:
- Documents, Desktop, Downloads (expected)
- AppData\Local, AppData\Roaming (where Python packages live)
- All subdirectories, no matter how deep
Windows Search sees:
.comextension → treats as application- File name “www.youporn.com” → suggests when typing “YouTube”
- No awareness that this is test data in a development directory
The indexing flow looks like this:
graph TD A[User Types in Windows Search] --> B{Indexed Locations?} B -->|User Profile| C[Search All Files] B -->|Excluded Path| D[Skip Directory] C --> E[Match Found: www.youporn.com] E --> F[Show as Application in Results] F --> G[User Sees Inappropriate Suggestion] G --> H[Colleague Sees It Too]Windows has no built-in exclusions for:
- Python virtual environments
- Conda package directories
- Node_modules
- Go modules
- Rust cargo directories
Developers are on their own.
Solution 1: Windows Indexing Options GUI (Individual Fix)
I started with the built-in Windows Indexing Options.
Step 1: Open Indexing Options
- Press
Windows + R - Type
control.exe /name Microsoft.IndexingOptions - Press Enter
Or: Control Panel → Indexing Options
Step 2: Review Indexed Locations
I saw “Indexing: x items (Complete)” with two main locations:
- Microsoft Outlook (if installed)
C:\Users\YourName
Step 3: Click Advanced → Indexed Locations
This shows the full tree of indexed paths.
Step 4: Expand User Profile and Examine
I found:
C:\Users\YourName(checked)AppData(checked)Local(checked)Continuum(checked)anaconda3(checked)pkgs← This needs to be excluded
Step 5: Exclude Python Package Directories
I unchecked these boxes:
C:\Users\YourName\AppData\Local\Continuum\anaconda3\pkgsC:\Users\YourName\AppData\Local\Programs\PythonC:\Users\YourName\AppData\Roaming\PythonC:\Users\YourName\.conda
Step 6: Rebuild the Index
Clicked “Advanced” → “Rebuild”
This took 15 minutes on my machine. Windows re-scanned everything except the excluded paths.
Result: The “YouPorn” suggestion disappeared from Windows Search.
Solution 2: PowerShell Script for Automated Exclusions
I manage multiple Python environments. Manually unchecking boxes in the GUI wasn’t sustainable.
I needed a script to:
- Find all Python package directories
- Exclude them from Windows Search
- Make it repeatable across machines
Problem: Windows Search doesn’t expose a clean PowerShell API for adding exclusions.
Workaround: Use the Registry.
Windows stores search exclusions in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gathering ManagerHKEY_CURRENT_USER\Software\Microsoft\Windows Search\Gathering ManagerBut these are binary blobs. Not directly editable via PowerShell.
Better approach: Use the Windows Search PowerShell module from the PowerShell Gallery.
First, install the module:
Install-Module -Name WindowsSearch -Scope CurrentUserThen, create a script to exclude common Python paths:
# Exclude Python package directories from Windows Search# Run this in an elevated PowerShell prompt
$ErrorActionPreference = "Stop"
# Common Python package paths to exclude$excludedPaths = @( "$env:USERPROFILE\AppData\Local\Continuum\anaconda3", "$env:USERPROFILE\AppData\Local\anaconda3", "$env:USERPROFILE\AppData\Local\Programs\Python", "$env:USERPROFILE\AppData\Roaming\Python", "$env:USERPROFILE\.conda", "$env:USERPROFILE\AppData\Local\pip")
# Check if paths exist before excluding$existingPaths = $excludedPaths | Where-Object { Test-Path $_ }
if ($existingPaths.Count -eq 0) { Write-Host "No Python directories found to exclude." exit 0}
Write-Host "Found $($existingPaths.Count) Python directories to exclude:"
foreach ($path in $existingPaths) { Write-Host " - $path"}
# Attempt to exclude using Windows Search utilities# Note: This requires manual confirmation via Indexing Options GUIWrite-Host "`nPlease manually exclude these paths in Indexing Options:"Write-Host "1. Press Windows+R"Write-Host "2. Type: control.exe /name Microsoft.IndexingOptions"Write-Host "3. Click Advanced → Indexed Locations"Write-Host "4. Uncheck the paths listed above"
# Alternative: Launch Indexing Options for the userStart-Process "control.exe" -ArgumentList "/name Microsoft.IndexingOptions"The script launches Indexing Options as a convenience. You still need to manually uncheck the boxes.
Why isn’t this fully automated?
Microsoft doesn’t expose a programmatic API for adding search exclusions. The Indexing Options GUI is the official method.
Solution 3: Enterprise Group Policy (IT Administrators)
If you’re managing developer workstations in an organization, use Group Policy.
Policy Path:
Computer Configuration → Administrative Templates → Windows SearchRelevant Policies:
-
“Set default exclusion paths for Windows Search”
- Define paths that Windows Search should never index
- Deploy to all machines via GPO
- Users can’t accidentally re-index these paths
-
“Do not allow locations to be added in Indexing Options”
- Lock down indexed locations
- Prevent users from adding problematic paths
- Useful for controlled environments
Example GPO Configuration:
Policy: Computer Configuration > Administrative Templates > Windows SearchSetting: "Set default exclusion paths for Windows Search"Enable: YesExclusion Paths: %USERPROFILE%\AppData\Local\Continuum %USERPROFILE%\AppData\Local\anaconda3 %USERPROFILE%\AppData\Local\Programs\Python %USERPROFILE%\AppData\Roaming\Python %USERPROFILE%\.conda %USERPROFILE%\AppData\Local\pip %USERPROFILE%\.virtualenvs %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.*Deploy via:
- Group Policy Management Console
- Link to Developer Workstations OU
- Run
gpupdate /forceon target machines - Restart Windows Search service:
Restart-Service WSearch
This prevents the issue organization-wide before it starts.
Solution 4: Alternative Search Tools (Developers)
After dealing with Windows Search’s limitations, I explored alternatives.
Everything (voidtools)
What it is: Ultra-fast file search using NTFS indexing
Advantages:
- Instant search (indexes file names only, not content)
- Lightweight (~1MB RAM)
- Doesn’t index by default—you choose what to index
- Portable version available
- Regularly updated
Download: https://www.voidtools.com/
Setup for Python development:
- Install Everything
- Open Tools → Options → Exclude
- Add these paths:
C:\Users\YourName\AppData\Local\ContinuumC:\Users\YourName\AppData\Local\anaconda3C:\Users\YourName\AppData\Local\Programs\PythonC:\Users\YourName\AppData\Roaming\PythonC:\Users\YourName\.conda
- Save and restart Everything
Result: Fast search without embarrassing suggestions.
Wox Launcher
What it is: Open-source launcher similar to Alfred (macOS) or Spotlight (Linux)
Advantages:
- Plugin-based architecture
- Web search integration
- File search plugin with exclusions
- Customizable keyboard shortcuts
- Active development
Download: https://www.wox.one/
Setup:
- Install Wox
- Enable File Search plugin
- Configure exclusions in plugin settings
- Set custom hotkey (default: Alt + Space)
Comparison:
| Feature | Windows Search | Everything | Wox |
|---|---|---|---|
| Speed | Medium | Instant | Fast |
| Indexing | Automatic | Manual/Selective | Manual |
| Exclusions | After-the-fact | Proactive | Proactive |
| Web Search | Integrated | No | Yes (plugins) |
| Enterprise Support | Yes (GPO) | No | No |
| Developer-friendly | No | Yes | Yes |
Solution 5: Preventive Environment Setup (Best Practice)
I learned that prevention beats fixing. Here’s how I set up new Windows machines for Python development.
Option 1: Dedicated Development Partition
Create a separate drive or partition for development:
C:\ (Windows and apps)D:\dev (all development work)Exclude the entire D:\dev from Windows Search.
Benefits:
- All code in one location
- Single exclusion rule
- Easy to backup
- Separate from personal files
Option 2: Organized User Directory Structure
Keep virtual environments in predictable locations:
C:\dev\ ├── projects\ (individual project repos) ├── venvs\ (global virtual environments) └── conda\ (all conda environments)Exclude C:\dev from Windows Search once.
Option 3: Project-Level .venv Directories
Use .venv in project directories (Python 3.3+ standard):
C:\Users\YourName\source\ ├── project-a\ │ ├── .venv\ │ └── src\ └── project-b\ ├── .venv\ └── src\Add .venv to Windows Search exclusions:
C:\Users\YourName\source\**\.venvWindows Search supports wildcards in exclusion paths.
Document this in team onboarding:
# Windows Development Machine Setup
## Python Environment
1. Install Python to `C:\Python311` (not AppData)2. Create `C:\dev` for all development work3. Exclude `C:\dev` from Windows Search: - Windows+R → `control.exe /name Microsoft.IndexingOptions` - Advanced → Indexed Locations → Exclude C:\dev
## Virtual Environments
Use project-local `.venv` directories.Already excluded via `C:\dev` wildcard rule.
## Verification
After setup, verify Windows Search doesn't index package directories:1. Press Windows key2. Type "protego" (or any installed package)3. Should show: "No results found"Package Maintainer Best Practices
If you maintain Python packages, you can prevent this issue for your users.
Problem Test Data
The Protego library includes www.youporn.com as a test fixture. Legitimate choice for testing robots.txt parsing against real-world domains.
But on Windows, this causes embarrassment.
Better Practices
1. Use Example Domains
Instead of real adult domains:
www.example.comwww.example.orgtest.example.netThe example.com, example.org, and example.net domains are reserved for documentation and testing (RFC 2606).
2. Obfuscated Domain Names
If you need realistic testing:
www.example-p0rn.comtest.adult-site.examplephishing-target.evil.comHumans recognize the intent. Windows Search won’t suggest them.
3. Separate Test Data Package
Don’t ship test data with the main package:
protego/ # Main package (no test data)protego-tests/ # Test data (separate install)Users only install test data if they need it:
pip install protegopip install protego-tests # Optional, for developers4. Document Test Data Content
Add to README:
## Test Data
This package includes real-world domain names for testing robots.txt parsing.Some test fixtures include adult domain names (e.g., for testing adult site robots.txt).
On Windows, these may appear in Windows Search. Exclude the package directory:Transparency beats surprise.
My Trial-and-Error Process
Here’s what I tried before finding working solutions.
Attempt 1: Delete the Files
- Delete
www.youporn.comfromsite-packages - Problem: Reappears on every
pip install protego --upgrade - Verdict: Temporary fix, not sustainable
Attempt 2: Add Hidden Attribute
attrib +H www.youporn.com- Problem: Windows Search still indexes hidden files
- Verdict: Doesn’t work
Attempt 3: Move Files Outside User Profile
- Changed Anaconda install location to
C:\anaconda3 - Problem: New packages still went to
AppData\Local - Verdict: Incomplete solution
Attempt 4: Disable Windows Search Entirely
- Disabled Windows Search service
- Problem: Broke Start menu search, File Explorer search
- Verdict: Too extreme, breaks core Windows functionality
Attempt 5: Windows Indexing Options
- Excluded Python directories via GUI
- Rebuilt index
- Problem solved
- Verdict: Working solution, requires manual setup
Attempt 6: Alternative Search Tools
- Installed Everything Search
- Excluded Python directories
- Problem solved with better search performance
- Verdict: Best long-term solution for developers
What worked:
- Windows Indexing Options exclusions (immediate fix)
- Alternative search tools (better developer experience)
- Preventive environment setup (prevents future issues)
Why Microsoft Doesn’t Fix This
Windows Search lacks developer-aware defaults because:
- Target Audience: General users, not developers
- Backwards Compatibility: Can’t change default indexing behavior without breaking existing workflows
- Complexity: Detecting “development directories” is non-trivial
- Enterprise Control: IT admins manage exclusions via GPO, not default settings
Microsoft expects:
- Individual users to use Indexing Options GUI
- Organizations to deploy Group Policy
- Developers to use third-party tools
This isn’t changing soon.
What I Learned
The “YouPorn in Windows Search” incident taught me:
-
Windows Search has no developer awareness. It indexes everything in user profiles, including package test data.
-
Exclusions are manual. No API for programmatic exclusion. GUI or Group Policy only.
-
Alternative tools exist. Everything and Wox are developer-friendly alternatives.
-
Prevention beats reaction. Set up dedicated development directories and exclude them proactively.
-
Package maintainers can help. Use example domains, not real adult sites, in test fixtures.
-
Document for your team. Add Windows Search setup to onboarding docs.
-
Test your setup. After excluding directories, verify embarrassing files don’t appear in search results.
Now when I demo my machine, Windows Search shows YouTube, not YouPorn.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Microsoft Docs - Indexing Options in Windows 10 and 11
- 👨💻 Microsoft Docs - Windows Search Group Policy
- 👨💻 Microsoft Docs - Advanced Indexing Options
- 👨💻 PowerShell Gallery - Windows Search Module
- 👨💻 voidtools - Everything Search
- 👨💻 Wox Launcher
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments