pyserial,导入错误:没有名为串行的模块

问题描述 投票:0回答:8

我知道这个问题已经被问过好几次了,但我看到的解决方案都没有解决我的问题。

我一直在尝试在我的 Mac 中使用 Sublime Text 2 的串行库。

import serial

每次我致电该图书馆时,我都会收到以下消息:

  Traceback (most recent call last):
    File "/Users/andreapatri/Desktop/test.py", line 1, in <module>
      import serial
  ImportError: No module named serial
  [Finished in 0.0s with exit code 1] 

我已经安装了python 3

brew install python3

和pyserial

sudo pip install pyserial

我是 mac 新手。 你能告诉我如何修复这个错误吗?

python pyserial
8个回答
11
投票

我用这个解决了这个问题:

sudo easy_install pyserial

10
投票

这个命令解决了我在 ubuntu 上的问题:

sudo apt install python3-serial

3
投票

sudo python3 -m pip install pyserial
Mac OSx Catalina 10.15.6
上为我成功了。


2
投票

使用 python3 运行脚本。如果您尝试使用 python,您将收到此错误消息。

python3 <scriptname>.py

1
投票

使用Python pip:

pip install pyserial

0
投票

尝试使用pip3代替pip

pip3[.X]安装pyserial

.X是你的python3版本


0
投票

Python 2

sudo apt-get install python-serial

Python 3

sudo apt-get install python3-serial

0
投票

在 anaconda 命令提示符下尝试:

conda install -c anaconda pyserial

确保您的相关串行端口尚未被具有串行通信独占访问权限的其他程序或进程使用。

我希望这有帮助。😊

© www.soinside.com 2019 - 2024. All rights reserved.