Repository navigation
Troubleshooting Guide
This document provides solutions to common issues encountered when using or developing the Secure Browser project.
- Overview
- Installation Issues
- Runtime Issues
- Browser-Specific Issues
- Configuration Issues
- Network Issues
- Performance Issues
- Development Issues
- Getting Help
This guide helps you diagnose and resolve common problems with Secure Browser. Issues are categorized by type and include step-by-step solutions.
Symptom:
ModuleNotFoundError: No module named 'PyQt5'
Causes:
- Dependencies not installed
- Virtual environment not activated
- Incorrect Python version
Solutions:
- Activate Virtual Environment
# Linux/macOS
source .venv/bin/activate
# Windows
.venv\Scripts\activate- Install Dependencies
pip install -r requirements.txt- Verify Installation
pip list- Check Python Version
python --version
# Should be 3.7 or higherSymptom:
ERROR: Could not find a version that satisfies the requirement PyQt5
Causes:
- Incompatible Python version
- Missing system dependencies
- Network issues
Solutions:
- Update pip
pip install --upgrade pip- Install System Dependencies
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install python3-pyqt5 python3-pyqt5-dev python3-pyqt5.qtwebengineFedora:
sudo dnf install python3-qt5 python3-qt5-develmacOS:
brew install pyqt5 pyqt5-webengine- Use Alternative Installation Method
# Install from source
pip install PyQt5 --no-binary PyQt5Symptom:
ERROR: Could not find a version that satisfies the requirement tkinterweb
Causes:
- Missing Tkinter development headers
- Incompatible system
Solutions:
- Install Tkinter Development Headers
Ubuntu/Debian:
sudo apt-get install python3-tk python3-devFedora:
sudo dnf install python3-tkinter python3-develmacOS:
brew install python-tk- Verify Tkinter Installation
python -c "import tkinter; print('Tkinter installed')"Symptom:
ERROR: Could not find a version that satisfies the requirement pywebview
Causes:
- Missing system dependencies
- Incompatible platform
Solutions:
- Install System Dependencies
Ubuntu/Debian:
sudo apt-get install libwebkit2gtk-4.0-devFedora:
sudo dnf install webkit2gtk3-develmacOS:
# Usually no additional dependencies neededWindows:
# Ensure WebView2 is installed from Microsoft- Install with Specific Backend
pip install pywebview[gtk]
# or
pip install pywebview[qt]Symptom:
- Command executes but no window appears
- No error messages
Causes:
- Display issues (Linux)
- GUI framework not initialized
- Virtual display not set up
Solutions:
- Check Display Environment
echo $DISPLAY- Set Up Virtual Display (Linux)
sudo apt-get install xvfb
xvfb-run python main.py- Verify GUI Framework
python -c "from PyQt5.QtWidgets import QApplication; print('PyQt5 OK')"
python -c "import tkinter; print('Tkinter OK')"- Run with Verbose Output
python main.py --browser pyqt5
# Check for error messages in consoleSymptom:
- Application starts then immediately crashes
- Error message appears
Causes:
- Missing dependencies
- Configuration file corruption
- Incompatible libraries
Solutions:
- Check Error Logs
python main.py 2>&1 | tee error.log- Reset Configuration
mv config/user_settings.json config/user_settings.json.backup
python main.py- Run in Debug Mode
# Add to main.py
import logging
logging.basicConfig(level=logging.DEBUG)- Verify Dependencies
pip checkSymptom:
error: unrecognized arguments: --browser tkinter
Causes:
- Incorrect argument syntax
- Outdated main.py
- Argument parser not configured
Solutions:
- Check Help
python main.py --help- Verify main.py Configuration
# Ensure arguments are defined in main.py
parser.add_argument("--browser", choices=["pyqt5", "tkinter", "webview", "search"])- Use Correct Syntax
python main.py --browser tkinter
# Not
python main.py --browser=tkinterSymptom:
- Clicking close tab button doesn't work
- Tab remains open
Solutions:
- Check Signal Connection
# Verify signal is connected in hope.py
self.tabs.tabCloseRequested.connect(self.close_tab)- Check close_tab Method
def close_tab(self, index):
self.tabs.removeTab(index)- Restart Browser
- Close and reopen the browser
Symptom:
- Browser appears with default theme
- Colors not as expected
Solutions:
- Check StyleSheet Syntax
# Verify QSS syntax is correct
self.setStyleSheet("""
QMainWindow {
background-color: #2b2b2b;
}
""")- Check PyQt5 Version
pip show PyQt5
# Ensure version is 5.15.0 or higher- Force Theme Application
app = QApplication(sys.argv)
app.setStyle('Fusion')
app.setPalette(dark_palette)Symptom:
- Changes in settings dialog not persisted
- Settings reset on restart
Solutions:
- Check Dialog Return Value
if dialog.exec_(): # Only saves if OK is clicked
self.use_vpn = dialog.vpn_checkbox.isChecked()- Verify Settings Are Applied
# Add debug print
print(f"VPN: {self.use_vpn}")
print(f"JavaScript: {self.enable_javascript}")- Implement Persistent Storage
import json
def save_settings(self):
settings = {
"use_vpn": self.use_vpn,
"enable_javascript": self.enable_javascript,
"proxy": self.proxy
}
with open("config/user_settings.json", "w") as f:
json.dump(settings, f)Symptom:
- URL entered but page doesn't load
- Blank screen or error message
Solutions:
- Check tkinterweb Installation
pip show tkinterweb- Verify URL Format
# Ensure URL has scheme
if not url.startswith(("http://", "https://")):
url = "https://" + url- Check Network Connectivity
ping example.com
curl https://example.com- Test with Simple HTML
browser.html_frame.set_html("<h1>Test</h1>")
# If this works, issue is with URL loadingSymptom:
- Blacklisted/whitelisted sites still accessible
- Filtering rules not applied
Solutions:
- Verify Filter Configuration
print(f"Whitelist: {browser.whitelist}")
print(f"Blacklist: {browser.blacklist}")- Check URL Matching Logic
# Ensure prefix matching is correct
if any(url.startswith(blocked) for blocked in self.blacklist):
# Block the site- Test Filter Application
# Add debug output
print(f"Checking URL: {url}")
print(f"Matches blacklist: {any(url.startswith(b) for b in self.blacklist)}")- Reload After Configuration
# Settings may require page reload
self.reload_page()Symptom:
- JavaScript runs despite being disabled
- Scripts execute on pages
Solutions:
- Verify JavaScript Toggle
print(f"JavaScript enabled: {self.javascript_var.get()}")- Check Content Filter
if not enabled:
self.html_frame.set_content_filter(lambda content: None)
else:
self.html_frame.set_content_filter(None)- Reload Page After Toggle
self.toggle_javascript()
self.reload_page()- Note on Limitations
- tkinterweb may have limited JavaScript control
- Some scripts may still execute
Symptom:
- Tkinter controls appear but webview window doesn't
- No error message
Solutions:
- Check pywebview Installation
pip show pywebview- Verify Backend
import webview
print(f"Backend: {webview.get_backend()}")- Try Different Backend
webview.create_window("Test", "https://example.com", backend="qt")
# or
webview.create_window("Test", "https://example.com", backend="gtk")- Check System Dependencies
# Linux: webkit2gtk
# Windows: WebView2
# macOS: WebKit (built-in)Symptom:
- URL entered but webview doesn't navigate
- Stays on previous page
Solutions:
- Check URL Format
if not url.startswith(("http://", "https://")):
url = "http://" + url # WebView may need http- Verify load_url Call
webview.load_url(url)- Check for Errors
try:
webview.load_url(url)
except Exception as e:
print(f"Error: {e}")- Restart Application
- WebView may need restart to apply changes
Symptom:
FileNotFoundError: [Errno 2] No such file or directory: 'config/user_settings.json'
Solutions:
- Create Configuration Directory
mkdir -p config- Create Default Configuration
cat > config/user_settings.json << EOF
{
"home_url": "https://search.brave.com/",
"security": {
"https_enforcement": true,
"javascript_enabled": true,
"whitelist": [],
"blacklist": []
},
"proxy": {
"http": "",
"https": ""
}
}
EOF- Check File Path
ls -la config/user_settings.jsonSymptom:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes
Solutions:
- Validate JSON
python -m json.tool config/user_settings.json- Fix JSON Syntax
{
"home_url": "https://example.com",
"security": {
"https_enforcement": true
}
}- Use JSON Validator
- Use online JSON validator
- Check for trailing commas
- Ensure quotes are double quotes
Symptom:
- Settings changes lost after restart
- Configuration file not updated
Solutions:
- Check File Permissions
ls -la config/user_settings.json- Ensure Write Access
chmod 644 config/user_settings.json- Implement Save Function
import json
def save_config(self):
config = {
"home_url": self.home_url,
"security": {
"https_enforcement": True,
"javascript_enabled": self.javascript_var.get()
}
}
with open("config/user_settings.json", "w") as f:
json.dump(config, f, indent=2)- Call Save on Settings Change
def set_security_settings(self):
# ... apply settings ...
self.save_config()Symptom:
- All pages fail to load
- Network error messages
Solutions:
- Check Internet Connection
ping -c 4 google.com
curl https://example.com- Check Firewall
# Linux
sudo ufw status
# Windows
# Check Windows Firewall settings- Disable Proxy Temporarily
unset http_proxy
unset https_proxy- Test with Different Site
curl https://www.google.comSymptom:
- Proxy configured but traffic not routed
- Direct connection still used
Solutions:
- Verify Proxy URL Format
# Correct format
http://proxy.example.com:8080
http://username:password@proxy.example.com:8080- Test Proxy with curl
curl -x http://proxy.example.com:8080 https://example.com- Check Environment Variables
echo $http_proxy
echo $https_proxy- Verify Proxy Server
- Check proxy server is running
- Check proxy server logs
- Test proxy with another application
Symptom:
- SSL certificate errors
- Pages not loading due to certificate issues
Solutions:
- Check System Time
date
# Ensure system time is correct- Update Certificate Store
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install ca-certificates
sudo update-ca-certificatesmacOS:
# Certificates usually updated with OS updatesWindows:
# Update certificates via Windows Update- Disable Certificate Verification (Not Recommended)
# Only for testing
import ssl
ssl._create_default_https_context = ssl._create_unverified_contextSymptom:
- Pages load slowly
- UI is unresponsive
Solutions:
- Check System Resources
# Linux
top
htop
# Windows
Task Manager
# macOS
Activity Monitor- Close Unnecessary Tabs
- Reduce number of open tabs
- Each tab consumes memory
- Clear Cache
# Clear browser cache if applicable
# Implementation depends on browser backend- Disable JavaScript
- JavaScript can slow down page loading
- Disable if not needed
Symptom:
- Browser consumes excessive memory
- System slows down
Solutions:
- Monitor Memory Usage
# Linux
ps aux | grep python
# Check memory per tab/process- Use Lighter Browser Backend
- Tkinter browser uses less memory
- Consider switching from PyQt5 to Tkinter
- Restart Browser Regularly
- Memory leaks may accumulate
- Restart periodically
- Limit Tab Count
- Keep fewer tabs open
- Close tabs when not needed
Symptom:
- Browser consumes high CPU
- Fan runs constantly
Solutions:
- Identify Resource-Intensive Pages
- Check which pages cause high CPU
- Close those pages
- Disable Extensions
- Extensions may cause high CPU
- Disable unnecessary extensions
- Update Browser Engine
- Ensure PyQtWebEngine is up to date
pip install --upgrade PyQtWebEngine- Check for Infinite Loops
- Review custom code for loops
- Add timeout to long-running operations
Symptom:
ImportError: cannot import name 'Browser' from 'src.browsers'
Causes:
- Module not exported
- Circular imports
- Incorrect import path
Solutions:
- Check Module Exports
# src/browsers/__init__.py
from .hope import Browser
from .secure_browser import SimpleBrowser as SecureBrowser
from .modern_browser import SimpleBrowser as ModernBrowser- Check Import Path
# Correct
from src.browsers import Browser
# Incorrect
from browsers import Browser
from src.browsers.hope import Browser- Check PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:$(pwd)"- Run from Project Root
# Run from project directory, not subdirectory
python main.py
# Not
cd src && python ../main.pySymptom:
- Tests fail with errors
- Unexpected test results
Solutions:
- Run Tests with Verbose Output
pytest -v
pytest -vv- Run Specific Test
pytest tests/test_browsers/test_secure_browser.py::test_https_enforcement- Check Test Isolation
- Ensure tests don't depend on each other
- Use fixtures for setup/teardown
- Debug Test Failure
pytest --pdb- Update Test Expectations
- Test may need updating for new features
- Review test logic
Symptom:
flake8: E501 line too long
black: reformatted code
Solutions:
- Auto-format with Black
black src/- Fix Flake8 Errors
flake8 src/
# Fix reported issues manually- Configure Line Length
# In .flake8 or setup.cfg
[flake8]
max-line-length = 100- Ignore Specific Errors
flake8 src/ --ignore=E501,W503Symptom:
- Documentation fails to build
- Missing references
Solutions:
- Check Markdown Syntax
- Use markdown linter
- Validate links
- Check Code References
- Ensure code examples are correct
- Verify API references exist
- Build Documentation Locally
# If using Sphinx or similar tool
make docsBefore seeking help, collect the following information:
- System Information
python --version
pip list
uname -a # Linux/macOS
# or
systeminfo # Windows- Error Messages
- Copy full error traceback
- Include console output
- Configuration
cat config/user_settings.json- Steps to Reproduce
- Document exact steps
- Include minimal example if applicable
When reporting issues, include:
-
Clear Title
- Descriptive and concise
- Include component name
-
Description
- What you were trying to do
- What happened instead
- Expected behavior
-
Environment
- OS and version
- Python version
- Browser backend used
-
Steps to Reproduce
- Minimal reproduction steps
- Code examples if applicable
-
Error Messages
- Full traceback
- Console output
-
Additional Context
- Screenshots if applicable
- Configuration files
- Related issues
- GitHub Issues: Report bugs and request features
- GitHub Discussions: Ask questions and discuss ideas
- Documentation: Check existing documentation first
- Code Examples: Review similar implementations
| Issue | Quick Fix |
|---|---|
| Module not found | pip install -r requirements.txt |
| Browser won't start | Check display environment |
| Settings not saving | Verify file permissions |
| Pages not loading | Check network connection |
| Proxy not working | Test proxy with curl |
| High memory usage | Close tabs, restart browser |
| Import errors | Check PYTHONPATH |
| Tests failing | Run with verbose output |
- pdb: Python debugger
- logging: Python logging module
- print(): Simple debugging
- IDE Debugger: VS Code, PyCharm debuggers
- htop: System monitor (Linux)
- Activity Monitor: System monitor (macOS)
- Task Manager: System monitor (Windows)
- netstat: Network connections
Check application logs for detailed error information:
# Application logs
tail -f browser.log
# System logs
journalctl -u python
# or
tail -f /var/log/syslogThis troubleshooting guide covers the most common issues encountered with Secure Browser. If you continue to experience problems after trying these solutions, please collect the diagnostic information and report the issue through the appropriate channels.
Remember that many issues can be resolved by:
- Ensuring dependencies are properly installed
- Verifying configuration files
- Checking system resources
- Running the latest version of the software