在 Python 3.12 中使用 nixnet 函式庫時遇到錯誤: Attribute Error: module 'collections' has no attribute 'Mapping'

更新 Jan 3, 2025

產品資訊

驅動程式

  • NI-XNET

程式語言

  • Python

問題敘述

我用的Python版本是3.12;nixnet函式庫版本是0.3.2;Pycharm使用的社群版本是2023.2.5。

當我嘗試建立 CAN 通訊時,會遇到錯誤"Attribute Error: module 'collections' has no attribute 'Mapping' 
圖片.png

解決方案

該錯誤是因為相依性問題所引起的。
nixnet library會呼叫使用 collection library,但在 Python 3.12 中,collection library被移至 collections.abc。
可以透過更新 nixnet library以更改程式碼以引用 collections.abc 來解決此問題。