24

I'm trying out downloading PyYAML and install it following the instructions here http://pyyaml.org/wiki/PyYAML

So I downloaded the ZIP package: http://pyyaml.org/download/pyyaml/PyYAML-3.11.zip and then cd into that folder and run python setup.py --with-libyaml install, the error message I got is ext/_yaml.h:2:10: fatal error: 'yaml.h' file not found

But I checked the PyYAML-3.11 folder, the yaml.h is there...

UPDATE: I tried the methods here http://sandlininc.com/?p=500

$ sudo easy_install pip
$ brew install libyaml
$ sudo easy_install setuptools
$ pip install -U PyYAML

Then I tried the python setup.py --with-libyaml install again. I got the message error: /Library/Python/2.7/site-packages/_yaml.so: Permission denied

Did I miss anything? Why the permission was denied? Thank you!

Penny
  • 1,218
  • 1
  • 13
  • 32
  • Which distribution are you on? and did you install the yaml development package that contains the yaml.h header file? If you're on Debian try as root: apt-get install libyaml-dev . – StylusEater Dec 08 '15 at 19:45
  • 1
    Hi thanks! I'm using osx...I've updated my question and am curious about why the permission denied?? – Penny Dec 08 '15 at 20:05
  • Just an fyi, i think this is broken at least on Catalina (10.15.4) or sometime before that. I can't remember when it last worked though. – dtc May 07 '20 at 19:24

2 Answers2

28

You can solve the issue by reinstalling the pyyaml package after adding required dependent libraries. Following are the steps:

  1. Uninstall pyyaml

pip uninstall pyyaml

  1. Install below packages

apt-get install libyaml-dev libpython2.7-dev

  1. Install pyyaml again

pip install pyyaml

Vijay Shetty
  • 901
  • 10
  • 11
3

In MacOS the following solved the problem:

pip3 uninstall PyYaml
pip3 install PyYaml==5.2
Greg Witczak
  • 1,634
  • 4
  • 27
  • 56
Alex L
  • 1,069
  • 2
  • 18
  • 33
  • 1
    Highly recommend against this as PyYaml 5.4 and below has [critical vulnerabilities](https://www.cvedetails.com/cve/CVE-2020-14343/). My MacOS solution was to `brew install libyaml` for access to `yaml.h` – Casey Jul 13 '22 at 20:34