Python.h not found when building syntaxnet
I am trying to build syntaxnet using bazel.
I ran the command bazel test syntaxnet/... which after a certain time raised the following error:
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/jpeg_archive/jpeg-9a /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet │
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet │
ERROR: /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/tf/google/protobuf/BUILD:534:1: C++ compilation of rule '@tf//google/protobuf:pyext/_message.so' failed: gcc failed: error executing command /us│
r/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,now -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 ... (remaining 51 argument(s) skipped)│
: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. │
external/tf/google/protobuf/python/google/protobuf/pyext/descriptor.cc:33:20: fatal error: Python.h: No such file or directory │
#include <Python.h> │
^ │
compilation terminated. │
INFO: Elapsed time: 47.057s, Critical Path: 46.16s │
//syntaxnet:arc_standard_transitions_test NO STATUS │
//syntaxnet:beam_reader_ops_test NO STATUS │
//syntaxnet:graph_builder_test NO STATUS │
//syntaxnet:lexicon_builder_test NO STATUS │
//syntaxnet:parser_features_test NO STATUS │
//syntaxnet:parser_trainer_test NO STATUS │
//syntaxnet:reader_ops_test NO STATUS │
//syntaxnet:sentence_features_test NO STATUS │
//syntaxnet:shared_store_test NO STATUS │
//syntaxnet:tagger_transitions_test NO STATUS │
//syntaxnet:text_formats_test NO STATUS │
│
Executed 0 out of 11 tests: 11 were skipped.
What else do I need ?
I already had TensorFlow 0.8.0 installed on my system. I am not sure if there are anymore dependencies.
Hope you cloned the syntaxnet repo with --recursive to clone all dependencies like protobuf
@smaransmarty I have a question here.
Do I need to install TensorFlow again from scratch?
I deleted my previous repo and cloned it again from here with --recursive.
Then I went into models/syntaxnet.
:~/models/syntaxnet$ pwd
/home/animesh/models/syntaxnet
:~/models/syntaxnet$ ls
bazel-bin bazel-genfiles bazel-out bazel-syntaxnet bazel-testlogs beam_search_training.png Dockerfile ff_nn_schematic.png looping-parser.gif README.md sawman.png syntaxnet tensorflow third_party tools util WORKSPACE
I then ran bazel test syntaxnet/... util/..., but the build ends in an error:
:~/models/syntaxnet$ bazel test syntaxnet/... util/...
WARNING: /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/tf/WORKSPACE:1: Workspace name in /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/tf/WORKSPACE (@__main__) does not match the name given in the repository's definition (@tf); this will cause a build error in future versions.
WARNING: /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/re2/WORKSPACE:1: Workspace name in /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/re2/WORKSPACE (@__main__) does not match the name given in the repository's definition (@re2); this will cause a build error in future versions.
WARNING: /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/grpc/WORKSPACE:1: Workspace name in /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/grpc/WORKSPACE (@__main__) does not match the name given in the repository's definition (@grpc); this will cause a build error in future versions.
INFO: Found 65 targets and 12 test targets...
INFO: From Executing genrule @png_archive//:configure:
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/png_archive/libpng-1.2.53 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
/tmp/tmp.ua1p3Bqo7d /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/png_archive/libpng-1.2.53 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking how to print strings... printf
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for ANSI C header files... (cached) yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for working strtod... yes
checking for memset... yes
checking for pow... no
checking for pow in -lm... yes
checking for zlibVersion in -lz... yes
checking if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE... yes
checking if libraries can be versioned... yes
checking for symbol prefix...
configure: pkgconfig directory is ${libdir}/pkgconfig
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libpng.pc
config.status: creating libpng-config
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/png_archive/libpng-1.2.53 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
INFO: From Executing genrule @farmhash_archive//:configure:
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
/tmp/tmp.aHOurcBhLo /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether byte ordering is bigendian... no
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking if the compiler supports __builtin_expect... yes
checking if the compiler supports __builtin_bswap32... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
-------------------------------------------------
FarmHash Version 1.1.0
Prefix: '/usr/local'.
Compiler: 'g++ -g -O2'
Now type 'make [<target>]'
where the optional <target> is:
all - build everything
check - build and run tests
install - install everything
--------------------------------------------------
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
/home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/syntaxnet
/tmp/tmp.aHOurcBhLo/missing: Unknown `--is-lightweight' option
Try `/tmp/tmp.aHOurcBhLo/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
ERROR: /home/animesh/.cache/bazel/_bazel_animesh/88f0a91930b9aa6ad1f3500a82c97709/external/tf/google/protobuf/BUILD:534:1: C++ compilation of rule '@tf//google/protobuf:pyext/_message.so' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,now -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 ... (remaining 51 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from external/tf/google/protobuf/python/google/protobuf/pyext/repeated_scalar_container.cc:34:0:
external/tf/google/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h:37:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
INFO: Elapsed time: 15.901s, Critical Path: 15.30s
//syntaxnet:arc_standard_transitions_test NO STATUS
//syntaxnet:beam_reader_ops_test NO STATUS
//syntaxnet:graph_builder_test NO STATUS
//syntaxnet:lexicon_builder_test NO STATUS
//syntaxnet:parser_features_test NO STATUS
//syntaxnet:parser_trainer_test NO STATUS
//syntaxnet:reader_ops_test NO STATUS
//syntaxnet:sentence_features_test NO STATUS
//syntaxnet:shared_store_test NO STATUS
//syntaxnet:tagger_transitions_test NO STATUS
//syntaxnet:text_formats_test NO STATUS
//util/utf8:unicodetext_unittest NO STATUS
Executed 0 out of 12 tests: 12 were skipped.
sudo apt get install python-dev
@jag2kn I tried that but I got the same error again.
What is your python version?
this is the problem: #include <Python.h>
you dont need to install tensorflow again, but configure it by running cd models/syntaxnet/tensorflow ./configure
@smaransmarty Thanks that made it work.