[Python] Python, pyserial, No module named 'serial'

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am using python to interogate a USB Serial device (a nino tnc) I have 3 separate systems. Linux ubuntu with no issues Linux Rpi with no issues Windows 10 with issues.

    As it responds correctly in the 1st 2 systems I don't think it is a hardware issue.

    Windows 10 64 bit. Simple Test python code

    import serial
    port = serial.Serial('COM3',57000) # open serial port
    print(port.name) # check which port was really used
    port.write(b'hello') # write a string
    port.close() # close port


    Error message
    import serial
    ModuleNotFoundError: No module named 'serial'

    Check my system
    C:\\Users\\djcle\>python --version
    Python 3.9.6

    C:\\Users\\djcle\>pip --version
    pip 25.0.1 from c:\\users\\djcle\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\pip (python 3.9)

    C:\\Users\\djcle\>pip list modules
    Package Version

    -----------------

    future 1.0.0
    iso8601 2.1.0
    pip 25.0.1
    pyserial 3.5
    PyYAML 6.0.2
    serial 0.0.97
    setuptools 56.0.0


    pyserial is there ok. I thought serial was part of pyserial?

    this works fine

    import sys
    print("sys version")
    print(sys.version)
    print()
    print("sys.path")
    print(sys.path)`


    Output below

    ====================================================== RESTART: G:/Radio/Packet_APRS/tnc-tools/tnc-tools/SERIALTEST2.py ======================================================
    sys version
    3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) \[MSC v.1934 64 bit (AMD64)\]

    sys.path
    \['G:/Radio/Packet_APRS/tnc-tools/tnc-tools', 'G:\\Radio\\Packet_APRS\\tnc-tools\\tnc-tools', 'C:\\Users\\djcle\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 'C:\\Users\\djcle\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 'C:\\Users\\djcle\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 'C:\\Users\\djcle\\AppData\\Local\\Programs\\Python\\Python311', 'C:\\Users\\djcle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages'\]


    Checking where pyserial is installed

    C:\Users\djcle>pip install pyserial Requirement already satisfied: pyserial in c:\users\djcle\appdata\local\programs\python\python39\lib\site-packages (3.5)


    Now on my two Linux machines above works fine.

    I have been trying to sort this out for 2 days.

    Help please!

    What I have tried is documented in main message.

    Perhaps somebody has encountered and solved this issue?

    Continue reading...

Compartilhe esta Página