admin管理员组文章数量:1356304
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?
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?
Share Improve this question asked Mar 28 at 4:20 David LeckieDavid Leckie 11 bronze badge 2- This question is similar to: ImportError: No module named serial. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – Joooeey Commented Mar 28 at 10:55
- Please clarify how you ran your Python code on Windows. – Joooeey Commented Mar 28 at 10:57
1 Answer
Reset to default 0You installed pyserial in your Python39 environment. It's not there in your Python311 environment. So either you need to run your program in the Python39 environment or install pyserial in the Python311 environment.
本文标签: pythonpyserialNo module named 39serial39Stack Overflow
版权声明:本文标题:Python, pyserial, No module named 'serial' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744057511a2583520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论