# Raspberry Pi 疑難排解指南 本指南提供在 Raspberry Pi 設備上運行物聯網項目時常見問題的解決方案。 它為遵循物聯網新手課程的初學者而設計,但對一般 Pi 開發也很有用。 --- ## 1. 安裝與依賴錯誤 ### ❗ `ModuleNotFoundError: No module named 'xyz'` 當所需的 Python 模組未安裝時會發生此錯誤。 **修正方法** ```bash pip3 install Permission denied when running scripts Often caused by accessing GPIO, I2C or system hardware without elevated privileges. Quick fix: sudo python3 script.py Recommended fix (no sudo needed every time): sudo usermod -aG gpio,i2c,spi $USER sudo reboot 2. GPIO / I2C / SPI Not Working ❗ RuntimeError: No access to GPIO Add user to GPIO group: sudo usermod -aG gpio $USER sudo reboot ❗ I2C / SPI devices not detected Enable interfaces: sudo raspi-config → Interface Options → Enable I2C / Enable SPI Check if I2C device appears: i2cdetect -y 1 3. Camera / Video Issues ❗ Camera not detected or fails to start Enable camera interface: sudo raspi-config → Interface Options → Camera → Enable sudo reboot Check if camera is visible: vcgencmd get_camera 4. Wi-Fi / SSH / Connectivity Problems | Problem | Fix | | -------------------------------- | --------------------------------------------- | | SSH connection refused | `sudo raspi-config → Interface Options → SSH` | | Device not showing on network | Check IP using: `hostname -I` | | Slow Wi-Fi / unstable connection | Prefer 2.4 GHz band, update OS | | Unable to access Pi headless | Add `ssh` file to boot partition | 5. Performance Issues Raspberry Pi running slow / laggy Close unused applications Reduce background services Use Lite OS if no desktop needed Ensure sufficient power supply (5V/3A or better) Check CPU load: top htop Storage issues: sudo apt autoremove sudo apt clean df -h --- **免責聲明**: 本文件由AI翻譯服務[Co-op Translator](https://github.com/Azure/co-op-translator)翻譯。儘管我們努力追求準確性,但請注意自動翻譯可能包含錯誤或不準確之處。原始文件的母語版本應視為權威來源。對於重要資訊,建議使用專業人工翻譯。我們不對因使用本翻譯而引起的任何誤解或誤譯承擔責任。