Installing Pyyaml with libyaml support on MacOS

Posted on Wed 13 May 2020 in yaml, libyaml, macos

I faced issue while installing Pyyaml with libyaml support on Mac OS Mojave. But I was able to successfully install at the end. Here, are some instructions

# wget https://github.com/yaml/pyyaml/archive/5.3.1.zip
# unzip pyyaml-5.3.1.zip
# cd pyyaml-5.3.1

If you run make without cython package you will get the following error -

clang: error: no such file or directory: 'ext/_yaml.c'

In order to rectify this error -

# pip install cython

You will need libyaml header files as well, you can install this -

# brew install libyaml

Finally, include LDFLAGS and CFLAGS to use custom location for make command like -

# LDFLAGS="-L/usr/local/lib/" CFLAGS="-I/usr/local/Cellar/libyaml/0.2.2/include" make installext

You will be greeted with success message like -

running install_egg_info
Writing /Volumes/data/venv3.8/lib/python3.8/site-packages/PyYAML-5.3.1-py3.8.egg-info

Let me know if you need any help.