[英]Can not import PySerial even though it's installed
I'm trying to import PySerial import serial
, but i get a ModuleNotFoundError: No module named 'serial'
.我正在尝试导入 PySerial
import serial
,但我得到一个ModuleNotFoundError: No module named 'serial'
。 I installed PySerial via conda install pyserial
and I also tried with pip install pyserial
in both cases I get the same error, but if execute conda list
or pip list
pyserial appears in the list.我通过 conda
conda install pyserial
安装了 PySerial 并且我还尝试使用pip install pyserial
在这两种情况下我都会遇到相同的错误,但是如果执行 conda conda list
或pip list
pyserial 出现在列表中。 I'm using VS Code on Windows and unistalled and reinstalled Anconda, VS Code and PySerial serveral times.我在 Windows 上使用 VS Code,并多次卸载并重新安装了 Anconda、VS Code 和 PySerial。 I checked also, that there is not the
serial
package.我还检查了,没有
serial
package。
Can anybody tell me why I can not import serial
?谁能告诉我为什么我不能
import serial
?
Edit:编辑:
I also tried conda install -c conda-forge pyserial
once...我也试过
conda install -c conda-forge pyserial
一次......
Probably you are not running the python version you think you are.可能您没有运行您认为的 python 版本。
Find full path of the Python interpreter? 找到 Python 解释器的完整路径?
try:尝试:
import sys
print(sys.executable)
And see if it matches what you expect.看看它是否符合您的期望。
If you don't know what to expect, it's more likely you aren't running the right pip.如果您不知道会发生什么,很有可能您没有运行正确的 pip。 In that case you could make sure to run the right pip like this:
在这种情况下,您可以确保像这样运行正确的 pip:
python -m pip install pyserial
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.