Bug: Can't run on Termux

Đang mở Phù hợp với người mới
#969 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@sqbi-q đang làm issue này rồi.

Từ ngày 10/8/2026.

  • #970 của @sqbi-q — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu bằng cách đọc meshtastic/util.py, nơi serial.tools.list_ports được import, và truy vết điểm vào của CLI thông qua meshtastic/__main__.py. Tái hiện lỗi import trên nền tảng không được hỗ trợ trong Termux hoặc môi trường tương đương, sau đó điều chỉnh cách xử lý import để vẫn sử dụng được thư viện mà không gặp ngoại lệ liệt kê. Xác minh rằng việc import Meshtastic và chạy CLI trên Termux không còn bị treo, đồng thời thêm hoặc chạy các bài kiểm thử liên quan đến hành vi cổng nối tiếp dựa trên nền tảng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Importing serial.tools.list_ports causes an exception when the platform is unsupported. This stops both CLI and import of Meshtastic as a library. One of those unsupported platforms is Termux (detected as posix). Termux should be able to run Meshtastic as the documentation provides install instructions for this platform, though.

~ $ meshtastic
don't know how to enumerate ttys on this system.
! I you know how the serial ports are named send this information to
! the author of this module:

sys.platform = 'android'
os.name = 'posix'
pySerial version = 3.5

also add the naming scheme of the serial ports and with a bit luck you can get
this module running...
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/meshtastic", line 3, in <module>
    from meshtastic.__main__ import main
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/__init__.py", line 88, in <module>
    from meshtastic.node import Node
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/node.py", line 11, in <module>
    from meshtastic.util import (
    ...<10 lines>...
    )
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/util.py", line 22, in <module>
    import serial.tools.list_ports # type: ignore[import-untyped]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/serial/tools/list_ports.py", line 31, in <module>
    from serial.tools.list_ports_posix import comports
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/serial/tools/list_ports_posix.py", line 114, in <module>
    raise ImportError("Sorry: no implementation for your platform ('{}') available".format(os.name))
ImportError: Sorry: no implementation for your platform ('posix') available

My suggested fix is to wrap import between try-except block:

import serial
try:
    import serial.tools.list_ports
except ImportError as e:
    print("Error: ", e)
    print("Error: Cannot list ports on this platform")
    print("Warning: Skipping import serial.tools.list_ports")

in meshtastic/util.py.

Ngôn ngữ chính
Python
Star
855
Fork
355
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của meshtastic/python

Tất cả issue của meshtastic/python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.