No module named ‘yaml‘ 解决办法

错误现象:

Traceback (most recent call last):
  File "/home/pi/ble-uart-peripheral/uart_peripheral.py", line 16, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

一般来说,命令行使用以下命令就能解决问题:

pip install yaml

但是,很遗憾,结果提示如下:

pi@pi:~/HeatMap $ pip install yaml
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting yaml
  Could not find a version that satisfies the requirement yaml (from versions: )
No matching distribution found for yaml

其实正确的命令行内容应该是如下所示:

pip install pyyaml

结果显示成功

pi@pi:~/HeatMap $ pip install pyyaml
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyyaml
  Downloading https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz (175kB)
    100% |████████████████████████████████| 184kB 481kB/s 
  Installing build dependencies ... done
Building wheels for collected packages: pyyaml
  Running setup.py bdist_wheel for pyyaml ... done
  Stored in directory: /home/pi/.cache/pip/wheels/2a/d4/92/cf299bdf4162957ca8126b46e913e29f76a4f17ca762c45028
Successfully built pyyaml
Installing collected packages: pyyaml
Successfully installed pyyaml-5.4.1
pi@pi:~/HeatMap $ 

猜你喜欢

转载自blog.csdn.net/jndingxin/article/details/125809878