You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派3B使用Python+pygogo日志报错:No module named builtins

Fixing "No module named builtins" Error with pygogo on Raspberry Pi 3B

Hey Vikram, let's get this pygogo error sorted out for you. That No module named builtins message is almost always tied to a Python version mismatch—here's why and how to fix it:

Why This Happens

Raspberry Pi 3B typically comes with both Python 2 and Python 3 pre-installed. The builtins module is a Python 3-only built-in module—Python 2 uses __builtin__ (with double underscores) instead. Since pygogo is designed for Python 3+, if you're running your script with Python 2, it'll throw this exact error.

Step-by-Step Fixes

  • Check your default Python version
    Run these commands in your terminal to confirm which versions you're working with:

    python --version
    python3 --version
    

    If python --version shows Python 2.x, that's the root cause.

  • Run your script with Python 3
    Instead of using python your_log_script.py, use the Python 3 interpreter explicitly:

    python3 your_log_script.py
    
  • Ensure pygogo is installed for Python 3
    If you originally installed pygogo with pip install pygogo, it probably got installed to your Python 2 environment. Install it for Python 3 instead:

    # First install pip3 if you don't have it
    sudo apt-get update && sudo apt-get install python3-pip -y
    # Then install pygogo for Python 3
    pip3 install pygogo
    

Bonus: Set Python 3 as your default (optional)

If you want to avoid this confusion in the future, you can set Python 3 as your default python command:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

That should resolve the builtins module error and get your pygogo logging up and running on the Pi 3B.

内容的提问来源于stack exchange,提问作者vikram eklare

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:04:23