Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant install allennlp with pip on mac

I am trying to install allennlp on my mac. I have tried installing macOS headers which solved the missing headers problem but now i am experiencing new problems.

The error when i run pip install allennlp:

Running setup.py bdist_wheel for jsonnet ... error
  Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-install-i4nyb384/jsonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-wheel-eof7cc6k --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  x86_64-apple-darwin13.4.0-clang++ -c -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 core/desugarer.cpp -o core/desugarer.o
  In file included from core/desugarer.cpp:17:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cassert:21:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/assert.h:44:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:111:82: error: use of undeclared identifier 'labs'; did you mean 'abs'?
  inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                                                                   ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:111:44: note: 'abs' declared here
  inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                             ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:113:81: error: use of undeclared identifier 'llabs'
  inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                                                                  ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:35: error: unknown type name 'ldiv_t'
  inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
                                    ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:95: error: use of undeclared identifier 'ldiv'; did you mean 'div'?
  inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
                                                                                                ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:42: note: 'div' declared here
  inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
                                           ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:118:34: error: unknown type name 'lldiv_t'
  inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
                                   ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:118:94: error: use of undeclared identifier 'lldiv'
  inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
                                                                                               ^
  In file included from core/desugarer.cpp:19:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:642:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:61:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:74:64: error: use of undeclared identifier 'strchr'
  char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
                                                                 ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:81:75: error: use of undeclared identifier 'strpbrk'
  char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
                                                                            ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:88:65: error: use of undeclared identifier 'strrchr'; did you mean 'strchr'?
  char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
                                                                  ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:76:13: note: 'strchr' declared here
  const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
              ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:95:76: error: use of undeclared identifier 'memchr'
  void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
                                                                             ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:74: error: use of undeclared identifier 'strstr'; did you mean 'strchr'?
  char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                           ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:13: note: 'strchr' declared here
        char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
              ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:74: error: no matching function for call to 'strchr'
  char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                           ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:13: note: candidate disabled: <no message provided>
        char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
              ^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:81: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
  char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                                  ^~~~
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:32: note: passing argument to parameter '__s' here
        char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
                                 ^
  In file included from core/desugarer.cpp:19:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:642:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:70:9: error: no member named 'memcpy' in the global namespace; did you mean 'memchr'?
  using ::memcpy;
        ~~^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:97:13: note: 'memchr' declared here
  const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
              ^
  In file included from core/desugarer.cpp:19:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:642:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:71:9: error: no member named 'memmove' in the global namespace
  using ::memmove;
        ~~^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:72:9: error: no member named 'strcpy' in the global namespace; did you mean 'strchr'?
  using ::strcpy;
        ~~^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:76:13: note: 'strchr' declared here
  const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
              ^
  In file included from core/desugarer.cpp:19:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:642:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:73:9: error: no member named 'strncpy' in the global namespace
  using ::strncpy;
        ~~^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:74:9: error: no member named 'strcat' in the global namespace; did you mean 'strchr'?
  using ::strcat;
        ~~^
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:76:13: note: 'strchr' declared here
  const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
              ^
  In file included from core/desugarer.cpp:19:
  In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:642:
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:75:9: error: no member named 'strncat' in the global namespace
  using ::strncat;
        ~~^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  make: *** [Makefile:118: core/desugarer.o] Error 1
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-install-i4nyb384/jsonnet/setup.py", line 75, in <module>
      test_suite="python._jsonnet_test",
    File "/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/anaconda3/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 188, in run
      self.run_command('build')
    File "/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/qf/jkn4v43j08xgst0r9yxyl0dc0000gn/T/pip-install-i4nyb384/jsonnet/setup.py", line 54, in run
      raise Exception('Could not build %s' % (', '.join(LIB_OBJECTS)))
  Exception: Could not build core/desugarer.o, core/formatter.o, core/libjsonnet.o, core/lexer.o, core/parser.o, core/pass.o, core/static_analysis.o, core/string_utils.o, core/vm.o, third_party/md5/md5.o

  ----------------------------------------
  Failed building wheel for jsonnet
  Running setup.py clean for jsonnet
Failed to build jsonnet

My compiler and gcc:

(base) Sakets-MacBook-Pro:usr saketkhandelwal$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
(base) Sakets-MacBook-Pro:usr saketkhandelwal$ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /anaconda3/bin

How do i fix this, i have tried reinstalling command line tools and package headers but still no luck.

like image 597
Saket Khandelwal Avatar asked Mar 05 '23 00:03

Saket Khandelwal


1 Answers

  • I suppose you can resolve this by updating to latest version of anaconda
  • Try to install jsonnet separately using conda install -c conda-forge jsonnet and then pip install allennlp

Please refer to this issue on allennlp github for more details :

Pip3 install failing on jsonnet

like image 56
Sundeep Pidugu Avatar answered Mar 09 '23 07:03

Sundeep Pidugu