-
Notifications
You must be signed in to change notification settings - Fork 6
docs: Document Windows terminal encoding support & troubleshooting #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| --- | ||
| title: "Windows Terminal Encoding" | ||
| sidebarTitle: "Windows Encoding" | ||
| description: "Fix UnicodeEncodeError on Windows CMD/PowerShell and get full Rich output" | ||
| icon: "terminal" | ||
| --- | ||
|
|
||
| PraisonAI automatically handles Windows legacy code pages to prevent CLI crashes and ensure ASCII-safe output. | ||
|
|
||
| ```mermaid | ||
| graph TB | ||
| Start[praisonai --help] --> Detect{Windows +<br/>legacy code page?} | ||
| Detect -->|No| Rich[Full Rich output<br/>emoji + box drawing] | ||
| Detect -->|Yes| Safe[Safe Console<br/>ASCII box, no emoji] | ||
| Safe --> Fallback{Still<br/>UnicodeEncodeError?} | ||
| Fallback -->|No| Safe | ||
| Fallback -->|Yes| Hint[Print remediation:<br/>set PYTHONIOENCODING=utf-8] | ||
|
|
||
| classDef input fill:#6366F1,stroke:#7C90A0,color:#fff | ||
| classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff | ||
| classDef success fill:#10B981,stroke:#7C90A0,color:#fff | ||
| classDef warning fill:#8B0000,stroke:#7C90A0,color:#fff | ||
|
|
||
| class Start input | ||
| class Detect,Fallback decision | ||
| class Rich,Safe success | ||
| class Hint warning | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| <Steps> | ||
| <Step title="Automatic Handling"> | ||
| PraisonAI ≥ v0.0.x automatically detects legacy Windows code pages and renders ASCII-safe output: | ||
|
|
||
| ```bash | ||
| praisonai --help | ||
| ``` | ||
|
|
||
| No configuration needed - the CLI will work without crashes. | ||
| </Step> | ||
|
|
||
| <Step title="Enable Full UTF-8 (Optional)"> | ||
| For full emoji and box-drawing characters, manually enable UTF-8: | ||
|
|
||
| <CodeGroup> | ||
| ```powershell PowerShell | ||
| $env:PYTHONIOENCODING='utf-8' | ||
| chcp 65001 | ||
| praisonai --help | ||
| ``` | ||
|
|
||
| ```cmd CMD | ||
| set PYTHONIOENCODING=utf-8 | ||
| chcp 65001 | ||
| praisonai --help | ||
| ``` | ||
| </CodeGroup> | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| --- | ||
|
|
||
| ## How It Works | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant CLI as PraisonAI CLI | ||
| participant Console as Rich Console | ||
| participant Terminal as Windows Terminal | ||
|
|
||
| CLI->>Console: Initialize with legacy_windows=True | ||
| Console->>Terminal: Detect code page | ||
| Terminal-->>Console: CP1252/CP850/ASCII | ||
| Console->>Console: Enable safe_box, no emoji | ||
| Console-->>CLI: ASCII-safe rendering | ||
| CLI-->>Terminal: Success (no crash) | ||
| ``` | ||
|
|
||
| | Component | Behavior | Fallback | | ||
| |-----------|----------|----------| | ||
| | **Rich Console** | Detects legacy code page | Uses ASCII boxes, no emoji | | ||
| | **PYTHONIOENCODING** | Set to utf-8 for subprocess safety | Prevents child process crashes | | ||
| | **Error Handling** | Catches UnicodeEncodeError | Shows remediation hint | | ||
|
|
||
| --- | ||
|
|
||
| ## Configuration Options | ||
|
|
||
| The automatic encoding detection requires no configuration. However, you can override behavior: | ||
|
|
||
| | Method | Scope | When to Use | | ||
| |--------|-------|-------------| | ||
| | `PYTHONIOENCODING=utf-8` | Current session | Temporary fix for full Unicode | | ||
| | `chcp 65001` | Current session | Enable UTF-8 code page | | ||
| | System Environment Variables | Permanent | Set `PYTHONIOENCODING` globally | | ||
| | Windows Terminal | Best experience | Use modern terminal instead of CMD | | ||
|
|
||
| --- | ||
|
|
||
| ## Common Patterns | ||
|
|
||
| ### Problem: UnicodeEncodeError in Older Versions | ||
|
|
||
| **Symptom:** | ||
| ``` | ||
| UnicodeEncodeError: 'charmap' codec can't encode character '\u2500' in position 0 | ||
| ``` | ||
|
|
||
| **Solution:** | ||
| ```bash | ||
| # Temporary fix | ||
| set PYTHONIOENCODING=utf-8 | ||
| praisonai --help | ||
|
|
||
| # Or upgrade to latest version | ||
| pip install --upgrade praisonai | ||
| ``` | ||
|
Comment on lines
+111
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ### Pattern: Permanent UTF-8 Setup | ||
|
|
||
| **For PowerShell users:** | ||
| ```powershell | ||
| # Add to PowerShell profile | ||
| Add-Content $PROFILE '$env:PYTHONIOENCODING="utf-8"' | ||
| ``` | ||
|
|
||
| **For CMD users:** | ||
| ```cmd | ||
| # Set system environment variable | ||
| setx PYTHONIOENCODING utf-8 | ||
| ``` | ||
|
|
||
| ### Pattern: Windows Terminal Integration | ||
|
|
||
| **Use Windows Terminal instead of legacy CMD:** | ||
| ```json | ||
| // Windows Terminal settings.json | ||
| { | ||
| "profiles": { | ||
| "defaults": { | ||
| "font": { | ||
| "face": "Cascadia Code" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
Comment on lines
+137
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JSON code block contains a comment ( |
||
|
|
||
| --- | ||
|
|
||
| ## Best Practices | ||
|
|
||
| <AccordionGroup> | ||
| <Accordion title="Use Windows Terminal for Best Experience"> | ||
| Windows Terminal provides full UTF-8 support and modern terminal features. Download from the Microsoft Store or install via `winget install Microsoft.WindowsTerminal`. | ||
| </Accordion> | ||
|
|
||
| <Accordion title="Set Environment Variables Permanently"> | ||
| Instead of setting `PYTHONIOENCODING` in each session, add it to your system environment variables through System Properties → Environment Variables. | ||
| </Accordion> | ||
|
|
||
| <Accordion title="Consider WSL for Unix-like Experience"> | ||
| Windows Subsystem for Linux (WSL) provides a full Unix terminal experience without encoding issues. Install with `wsl --install`. | ||
| </Accordion> | ||
|
|
||
| <Accordion title="Upgrade to Latest PraisonAI Version"> | ||
| The automatic encoding detection was added in recent versions. Ensure you're running the latest version with `pip install --upgrade praisonai`. | ||
| </Accordion> | ||
| </AccordionGroup> | ||
|
|
||
| --- | ||
|
|
||
| ## Related | ||
|
|
||
| <CardGroup cols={2}> | ||
| <Card title="CLI Reference" icon="terminal" href="/cli/cli-reference"> | ||
| Complete CLI command reference | ||
| </Card> | ||
| <Card title="Installation Guide" icon="download" href="/installation"> | ||
| Getting started with PraisonAI | ||
| </Card> | ||
| </CardGroup> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version placeholder
v0.0.xshould be replaced with the specific version where automatic encoding detection was introduced to provide accurate guidance to users.