0

I have installed pyyaml by using pip install pyyaml on my mac, but I can't seem to use the module after installation, due to

ImportError: No module named 'yaml'

Version PyYAML-5.1.2

The Python version is 3.7.

I can't seem to understand why this happens. Can anyone shed some light on the matter?

Marius Mucenicu
  • 1,685
  • 2
  • 16
  • 25
Sun Yuting
  • 31
  • 1
  • 5
  • Do you also have Python 2.7.x installed on your system? In that case your `pip install` might have installed it for that version instead of Python 3.x. Do you have a `pip3` command as well? – Hampus Larsson Dec 02 '19 at 15:13
  • have you tried "python3 -m pip install pyyaml"? – Mrkinix Dec 02 '19 at 15:14
  • Yes I do have python 2.7.x in my system, but currently the default python version is 3.7. And I tried using the command "python3 -m pip install pyyaml", still the same... – Sun Yuting Dec 02 '19 at 15:22

1 Answers1

3

Try pip3.x install pyyaml where the 3.x corresponds to what version of Python you are using. For example I use pip3.6.

This is what worked for me, although you can look here for more options.

Jamie
  • 1,530
  • 1
  • 19
  • 35