#747·OpenManus

Fixing Browser Launch and Playwright Issues in OpenManus on WSL

Author: miracle777Created Mar 17, 2025Updated Sep 29, 2026
Labelsinactive

Bug description

問題の概要 | Issue Summary

日本語 | Japanese

WSL (Windows Subsystem for Linux) 環境でOpenManusを実行すると、以下の問題が発生しました:

1.ブラウザが起動できない 2.Playwrightの実行エラー 3.ヘッドレスモードでのJavaScript実行の制限

English | 英語

When running OpenManus on WSL (Windows Subsystem for Linux), the following issues occur:

1.The browser fails to launch 2.Playwright execution errors 3.JavaScript execution limitations in headless mode

解決策 | Proposed Solutions

1. Playwrightの設定修正 | Modify Playwright Configuration

日本語 | Japanese launch_browser.py の修正により、ブラウザの起動を安定させます。

python

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    print("Launching Playwright browser...")
    browser = p.chromium.launch(
        headless=False,  # GUIを表示
        args=[
            "--remote-debugging-port=9222",
            "--remote-debugging-address=0.0.0.0",
            "--disable-gpu",
            "--disable-software-rasterizer",
            "--disable-setuid-sandbox",
            "--disable-dev-shm-usage",
            "--no-sandbox",
            "--no-zygote",
        ],
    )

    # 新しいコンテキストとページを作成
    context = browser.new_context()
    page = context.new_page()

    # OpenManusの初期ページを表示
    page.goto("about:blank")  # 空白ページを表示
    page.set_content(
        """
    <html>
        <head>
            <title>OpenManus Browser</title>
            <style>
                body {
                    font-family: Arial, sans-serif;
                    margin: 40px;
                    background-color: #f5f5f5;
                }
                .container {
                    background-color: white;
                    padding: 20px;
                    border-radius: 8px;
                    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
                }
                h1 {
                    color: #333;
                    margin-bottom: 20px;
                }
                .status {
                    color: #4CAF50;
                    font-size: 18px;
                }
                .info {
                    margin-top: 20px;
                    color: #666;
                }
            </style>
        </head>
        <body>
            <div class="container">
                <h1> OpenManus Browser</h1>
                <div class="status">✅ ブラウザが正常に起動しました</div>
                <div class="info">
                    <p>デバッグポート: <code>http://localhost:9222</code></p>
                    <p>このウィンドウは開いたままにしてください。</p>
                    <p>OpenManusがこのブラウザを使用して操作を行います。</p>
                </div>
            </div>
        </body>
    </html>
    """
    )

    print("Browser is running with remote debugging at: http://localhost:9222")
    print("Playwright browser launched successfully. Keep this process running.")

    try:
        input("Press Enter to exit...")
    finally:
        context.close()
        browser.close()

English | 英語 Modify launch_browser.py to stabilize the browser launch process.

2. 設定ファイルの更新 | Update Configuration File

日本語 | Japanese config/config.toml を更新して、WSL環境に適したブラウザ設定を追加します。

tolm

# Browser configuration for WSL environment
[browser]
headless = false  # GUIを表示
disable_security = true
extra_chromium_args = [
    "--no-sandbox",
    "--disable-gpu",
    "--disable-dev-shm-usage",
    "--disable-setuid-sandbox",
    "--remote-debugging-port=9222",
    "--remote-debugging-address=0.0.0.0"
]

cdp_url = "http://localhost:9222"

English | 英語 Update config/config.toml to include browser settings optimized for the WSL environment.

3. 必要なパッケージのインストール | Install Required Packages

日本語 | Japanese 以下のコマンドを実行して、必要なパッケージをインストールします。

bash
pip install playwright==1.49.0
playwright install chromium
sudo apt-get install -y xvfb  # X11関連パッケージ(必要な場合)

English | 英語 Run the following commands to install the required packages.

bash
pip install playwright==1.49.0
playwright install chromium
sudo apt-get install -y xvfb  # X11-related package (if needed)

4. メインプログラムの日本語対応 | Japanese Localization in Main Program

日本語 | Japanese main.py を修正し、日本語のメッセージを追加します。

python
async def main():
    agent = Manus()
    try:
        prompt = input("指示を入力してください: ")
        if not prompt.strip():
            logger.warning("❌ 入力が空です。")
            return

        logger.warning(" リクエストを処理中...")
        await agent.run(prompt)
        logger.info("✅ 処理が完了しました。")

        logger.info(" 実行結果:")
        logger.info("  • ブラウザ操作: 完了")
        logger.info("  • データ処理: 完了")
        if "保存" in prompt or "ダウンロード" in prompt:
            logger.info("  • ファイル保存: 完了")

    except KeyboardInterrupt:
        logger.warning("⚠️ 操作が中断されました。")
    except Exception as e:
        logger.error(f"❌ エラーが発生しました: {str(e)}")
    finally:
        await agent.cleanup()
        logger.info(" セッションを終了しました。")

English | 英語 Modify main.py to add Japanese messages for better user feedback.

実行手順 | Execution Steps

日本語 | Japanese

1.設定ファイルを config/ に配置 2.ブラウザを起動

bash
python launch_browser.py

3.別ターミナルでメインプログラムを実行

bash
python main.py

English | 英語

1.Place the configuration file in config/. 2.Start the browser.

bash
python launch_browser.py

3.Run the main program in a separate terminal.

bash
python main.py

動作確認済みの機能 | Verified Features

日本語 | Japanese

  • ブラウザの表示と操作
  • JavaScriptを使用する動的ページ(Google Maps等)の操作
  • PDFの保存(「印刷」ダイアログが表示され、人間が保存ボタンをクリックする必要がある)
  • 要素の検知と操作

English | 英語

  • Browser display and interaction
  • Handling dynamic pages using JavaScript (e.g., Google Maps)
  • PDF saving (The "Print" dialog appears, and a human needs to manually click the save button.)
  • Element detection and manipulation

注意点 | Notes

日本語 | Japanese

  1. headless = false の設定が推奨される
  2. 必要に応じて X11 設定が必要
  3. ブラウザのデバッグポート(9222)が利用可能であることを確認
  4. PDFの保存は完全自動ではなく、「印刷」ダイアログが表示された後に手動で保存ボタンをクリックする必要がある

English | 英語

  1. It is recommended to set headless = false.
  2. X11 configuration may be required.
  3. Ensure the browser debugging port (9222) is available.
  4. PDF saving is not fully automated; the "Print" dialog appears, and the user must manually click the save button.

参考情報 | Reference Information

  • WSL バージョン | WSL Version: WSL2
  • Python 環境 | Python Environment: Anaconda
  • Playwright バージョン | Playwright Version: 1.49.0
  • OS: Ubuntu 22.04 on Windows 11

Source: FoundationAgents/OpenManus