6
votes

Today I've upgraded python3.7 with brew upgrade command.

And I've tried to install PyYAML package with pip3.

I've got this error and have no idea..

% pip3 install PyYAML

    checking if libyaml is linkable
    clang build/temp.macosx-10.13-x86_64-3.7/check_libyaml.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -lyaml -o build/temp.macosx-10.13-x86_64-3.7/check_libyaml
    building '_yaml' extension
    creating build/temp.macosx-10.13-x86_64-3.7/ext
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c ext/_yaml.c -o build/temp.macosx-10.13-x86_64-3.7/ext/_yaml.o
    In file included from ext/_yaml.c:271:
    ext/_yaml.h:10:9: warning: 'PyString_CheckExact' macro redefined [-Wmacro-redefined]
    #define PyString_CheckExact PyBytes_CheckExact
            ^
    ext/_yaml.c:139:11: note: previous definition is here
      #define PyString_CheckExact          PyUnicode_CheckExact
              ^
    ext/_yaml.c:1410:17: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      __pyx_v_value = yaml_get_version_string();
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
    ext/_yaml.c:2577:52: warning: incompatible pointer types passing 'int (void *, char *, size_t, size_t *)' (aka 'int (void *, char *, unsigned long, unsigned long *)') to parameter of type 'yaml_read_handler_t *' (aka 'int (*)(void *, unsigned char *, unsigned long, unsigned long *)') [-Wincompatible-pointer-types]
        yaml_parser_set_input((&__pyx_v_self->parser), __pyx_f_5_yaml_input_handler, ((void *)__pyx_v_self));
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/yaml.h:1370:30: note: passing argument to parameter 'handler' here 

....... 

And finally

    /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
        PyObject *curexc_traceback;
                  ^
    51 warnings and 15 errors generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-exbgmayz/PyYAML/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-n11vy5s0/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-exbgmayz/PyYAML/

I've tried solve this problem, but still have no idea.

How can I resolve this issue..?

3
"May I help you..?" is asking if you can offer help to someone else. You probably want to ask something like "How can I resolve this issue?" What have you tried to solve this? - Anthon
Oh.. Thank you for let me know sir. - Byungwoo Jeon
check the workaround suggested in github.com/yaml/pyyaml/issues/152 - JL Peyret

3 Answers

6
votes

PyYAML's C extension do not compile on 3.7, that is what the error message is about and what some messages in the thread of issue 126 refer to. There is a mechanism in the PyYAML installer that should test if the C extension can be compiled, it mostly checks if libyaml is available.

I assumed you upgraded to 3.7.0 (instead of upgrading Python3.7 as you write) so I suggest you downgrade to 3.6. Although PyYAML's page on PyPI, indicates that only 3.4 and 3.5 are supported, 3.6 seems to be fine.

If you can't downgrade Python, and need the functionality of 3.7 now, you can consider using ruamel.yaml (disclaimer: I am the author of that package). It is essentially a superset of PyYAML, so normally doing

import ruamel.yaml as yaml

should get your program working. Since macOS wheels for 3.7 are available on PyPI installation should not cause any problems.

3
votes

Python 3.7 breaks the build for PyYaml. Use Python 3.6.

0
votes

yaml didnt work with python 3.7

Fix: downgrade to python2 and install yaml

  1. brew install python@2.
  2. brew install libyaml
  3. sudo python -m easy_install pyyaml.