-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
Common issues and how to fix them.
Problem: Python is not installed or not in PATH.
Solutions:
-
Install Python
- Download from python.org
- During installation, check "Add Python to PATH"
-
Try python3 instead
python3 "Python code/butterfly.py" -
Verify installation
python --version
Problem: Turtle module not found (rare, as it's built-in).
Solutions:
-
Check Python version
python --version
Make sure it's 3.x, not 2.x
-
Reinstall Python with standard library included
-
Try in IDLE
- Open Python IDLE
- File → Open → butterfly.py
- Run → Run Module (F5)
Problem: Missing turtle. done() or script error.
Solutions:
-
Check line 100 has:
turtle.done()
-
Run from terminal (not double-clicking) to see errors:
python "Python code/butterfly.py" -
Add error handling:
try: # ... your code ... turtle.done() except Exception as e: print(f"Error: {e}") input("Press Enter to close...")
Problem: Drawing is happening too fast or color issue.
Solutions:
-
Check colors aren't matching:
screen.bgcolor("black") pen.color("#ff69b4") # Must be different from black!
-
Slow down the drawing:
UPDATE_EVERY = 1 DELAY_SECONDS = 0.01
-
Check pen is down:
pen.pendown() # Should be on line 89
Problem: Scaling issues or wrong parameters.
Solutions:
-
Adjust MARGIN:
MARGIN = 0.95 # Use more of screen
-
Adjust STEP_DIVISOR:
STEP_DIVISOR = 30 # Larger butterfly STEP_DIVISOR = 80 # Smaller butterfly
-
Check window size:
screen.setup(width=900, height=900) # Increase if needed
Problem: Non-square window or wrong aspect ratio.
Solutions:
-
Use square dimensions:
screen.setup(width=900, height=900) # Equal width and height
-
Don't use widescreen:
# BAD: screen.setup(width=1600, height=900) # GOOD: screen.setup(width=900, height=900)
Problem: Too many points or updates.
Solutions:
-
Reduce points:
POINTS = 2000 # Instead of 5000
-
Update less frequently:
UPDATE_EVERY = 50 # Instead of 8
-
Remove delay:
DELAY_SECONDS = 0 # No pause
-
Fastest possible:
POINTS = 2000 UPDATE_EVERY = 2000 # Update only at end DELAY_SECONDS = 0
Problem: Updates happening too quickly.
Solutions:
-
Update more frequently:
UPDATE_EVERY = 1 # Every point
-
Add delay:
DELAY_SECONDS = 0.01 # 10 ms pause
-
Reduce speed (doesn't help with tracer off):
# This WON'T work because tracer is off # pen.speed(1)
Problem: Formula was modified incorrectly.
Solutions:
-
Reset to original:
r = math.exp(math.cos(t)) - 2 * math.cos(4 * t) - (math.sin(t / 12)) ** 5
-
Check parentheses:
# WRONG: math.sin(t / 12) ** 5 # RIGHT: (math.sin(t / 12)) ** 5
-
Check operator:
# WRONG: math.exp(math.cos(t)) + 2 * math.cos(4 * t) # RIGHT: math.exp(math.cos(t)) - 2 * math.cos(4 * t)
Problem: Missing import.
Solution:
Add at top of file:
import mathProblem: Invalid mathematical operation.
Solutions:
-
Check for division by zero:
# If you modified the formula, ensure no division by zero -
Check formula is correctly typed
-
Reset to working version
Problem: Color rendering or hex code issue.
Solutions:
-
Use valid hex codes:
pen.color("#ff69b4") # Must start with #
-
Use color names:
pen.color("pink") # Easier, but less precise
-
Test colors:
# Test different colors print(turtle.colormode()) # Should be 1. 0 or 255
Problem: Pen visibility setting.
Solution:
pen = turtle.Turtle(visible=False) # Line 22
# Or later:
pen.hideturtle()Problem: Too many points or computer too slow.
Solutions:
-
Reduce POINTS:
POINTS = 1000
-
Remove animation:
UPDATE_EVERY = 5000 DELAY_SECONDS = 0
-
Close other programs
Problem: Normal! Python is busy drawing.
Solution:
- Wait - the program is working
- If it truly hangs for >2 minutes, restart
- Reduce POINTS for faster completion
Problem: Wrong path or not in correct directory.
Solutions:
-
Check current directory:
pwd # On Mac/Linux cd # On Windows
-
List files:
ls # On Mac/Linux dir # On Windows
-
Navigate to correct folder:
cd Butterflies-in-my-IDE cd "Python code" python butterfly.py
-
Use quotes for paths with spaces:
python "Python code/butterfly.py"
Problem: Tkinter/turtle compatibility issue.
Solutions:
-
Use system Python 3:
python3 "Python code/butterfly.py" -
Install Python from python.org (not brew)
Problem: File encoding issues.
Solutions:
-
Save file as UTF-8 in your editor
-
Add encoding declaration at top:
# -*- coding: utf-8 -*-
Problem: Tkinter not installed.
Solutions:
-
Install Tkinter:
sudo apt-get install python3-tk # Ubuntu/Debian sudo yum install python3-tkinter # Fedora
- Check the error message carefully
- Search the error on Google or Stack Overflow
-
Open an issue on GitHub with:
- Your OS (Windows/Mac/Linux)
- Python version (
python --version) - Complete error message
- What you were trying to do
# Add at various points to debug:
print(f"min_x: {min_x}, max_x: {max_x}")
print(f"Scale: {scale}")
print(f"Total points: {len(raw_points)}")Before asking for help, try:
- Python 3.x is installed
- Running from correct directory
- All imports are at top of file
-
turtle. done()is at the end - Colors are different (pen ≠ background)
- Window dimensions are square
- Formula has correct parentheses
- No syntax errors (run in terminal to check)
Still stuck? Open an issue on GitHub! 🦋