Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pyyaml using pip/Add PyYaml as pip dependency

Tags:

python

pip

yaml

I want to use PyYaml in my pip project, but am having trouble using it as a dependency. Mainly the problem is thet PyYaml in pip is not a cross platform install.

How do I install pyyaml using pip so that it works. Note, on a current fresh Ubuntu install I get the following error when running pip install pyyaml

Installing collected packages: pyyaml
  Running setup.py install for pyyaml
    checking if libyaml is compilable
    gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -I/usr/include/python3.2mu -c build/temp.linux-x86_64-3.2/check_libyaml.c -o build/temp.linux-x86_64-3.2/check_libyaml.o
    build/temp.linux-x86_64-3.2/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
    compilation terminated.

    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)

Successfully installed pyyaml

Note that the error says "successfully installed" but it is not. I can not import yaml

I am not looking for answers that say "use apt-get" due to my very first sentence. I need the install to be cross platform and work as a pip dependency I am not simply wondering on how to install it correctly.

If this is not possible, is there any library I can use in replacement?

like image 974
Nick Humrich Avatar asked Jul 16 '14 21:07

Nick Humrich


People also ask

Is PyYAML included in Python?

PyYAML is a YAML parser and emitter for Python.

How install PyYAML on Windows?

Download suitable(Python version, 32/64 bit) .exe file from http://pyyaml.org/wiki/PyYAML, then double click it to install PyYAML to your Windows 10 PC following the wizard window. Just double click the .exe file, and flow the guide window, very simple.

Will pip install dependencies?

Pip is able to install packages configured with their dependencies, because most authors package their code as wheels by default before submitting to PyPI.


1 Answers

You will need some extra packages to build it.

First of all you need to uninstall pyyaml, or it will complain later that it is already installed

pip uninstall pyyaml

Then install the following packages:

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

Finally install it again

pip install pyyaml
like image 87
Salem Avatar answered Sep 18 '22 22:09

Salem