pip3 install allennlp 适用于 18.04,但不适用于 20.04,我该如何修复此错误?

pip3 install allennlp 适用于 18.04,但不适用于 20.04,我该如何修复此错误?

我已在 Ubuntu 18.04 上成功安装了适用于 Python 的 allennlp,但在升级到 20.04 后,我尝试重新安装所有内容,现在出现错误。这是我在终端上得到的结果。(我总是在 jsonnet 上遇到错误。)有什么帮助吗?

 Collecting allennlp
  Using cached allennlp-1.0.0-py3-none-any.whl (473 kB)
Requirement already satisfied: spacy<2.3,>=2.1.0 in ./.local/lib/python3.8/site-packages (from allennlp) (2.2.4)
Requirement already satisfied: filelock<3.1,>=3.0 in ./.local/lib/python3.8/site-packages (from allennlp) (3.0.12)
Requirement already satisfied: h5py in ./.local/lib/python3.8/site-packages (from allennlp) (2.10.0)
Requirement already satisfied: nltk in ./.local/lib/python3.8/site-packages (from allennlp) (3.5)
Requirement already satisfied: requests>=2.18 in /usr/lib/python3/dist-packages (from allennlp) (2.22.0)
Requirement already satisfied: tqdm>=4.19 in ./.local/lib/python3.8/site-packages (from allennlp) (4.48.2)
Requirement already satisfied: overrides==3.0.0 in ./.local/lib/python3.8/site-packages (from allennlp) (3.0.0)
Requirement already satisfied: scipy in ./.local/lib/python3.8/site-packages (from allennlp) (1.5.2)
Requirement already satisfied: transformers<2.12,>=2.9 in ./.local/lib/python3.8/site-packages (from allennlp) (2.11.0)
Requirement already satisfied: torch<1.6.0,>=1.5.0 in ./.local/lib/python3.8/site-packages (from allennlp) (1.5.1)
Requirement already satisfied: pytest in ./.local/lib/python3.8/site-packages (from allennlp) (6.0.1)
Requirement already satisfied: scikit-learn in ./.local/lib/python3.8/site-packages (from allennlp) (0.23.2)
Collecting jsonnet>=0.10.0; sys_platform != "win32"
  Using cached jsonnet-0.16.0.tar.gz (256 kB)
Requirement already satisfied: numpy in ./.local/lib/python3.8/site-packages (from allennlp) (1.19.1)
Requirement already satisfied: jsonpickle in ./.local/lib/python3.8/site-packages (from allennlp) (1.4.1)
Requirement already satisfied: boto3 in ./.local/lib/python3.8/site-packages (from allennlp) (1.14.41)
Requirement already satisfied: tensorboardX>=1.2 in ./.local/lib/python3.8/site-packages (from allennlp) (2.1)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (1.0.2)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy<2.3,>=2.1.0->allennlp) (45.2.0)
Requirement already satisfied: srsly<1.1.0,>=1.0.2 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (1.0.2)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (2.0.3)
Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (0.7.1)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (0.4.1)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (1.1.3)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (3.0.2)
Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (1.0.0)
Requirement already satisfied: thinc==7.4.0 in ./.local/lib/python3.8/site-packages (from spacy<2.3,>=2.1.0->allennlp) (7.4.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from h5py->allennlp) (1.14.0)
Requirement already satisfied: click in /usr/lib/python3/dist-packages (from nltk->allennlp) (7.0)
Requirement already satisfied: joblib in ./.local/lib/python3.8/site-packages (from nltk->allennlp) (0.16.0)
Requirement already satisfied: regex in ./.local/lib/python3.8/site-packages (from nltk->allennlp) (2020.7.14)
Requirement already satisfied: packaging in ./.local/lib/python3.8/site-packages (from transformers<2.12,>=2.9->allennlp) (20.4)
Requirement already satisfied: sacremoses in ./.local/lib/python3.8/site-packages (from transformers<2.12,>=2.9->allennlp) (0.0.43)
Requirement already satisfied: sentencepiece in ./.local/lib/python3.8/site-packages (from transformers<2.12,>=2.9->allennlp) (0.1.91)
Requirement already satisfied: tokenizers==0.7.0 in ./.local/lib/python3.8/site-packages (from transformers<2.12,>=2.9->allennlp) (0.7.0)
Requirement already satisfied: future in /usr/lib/python3/dist-packages (from torch<1.6.0,>=1.5.0->allennlp) (0.18.2)
Requirement already satisfied: py>=1.8.2 in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (1.9.0)
Requirement already satisfied: pluggy<1.0,>=0.12 in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (0.13.1)
Requirement already satisfied: iniconfig in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (1.0.1)
Requirement already satisfied: toml in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (0.10.1)
Requirement already satisfied: more-itertools>=4.0.0 in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (8.4.0)
Requirement already satisfied: attrs>=17.4.0 in ./.local/lib/python3.8/site-packages (from pytest->allennlp) (19.3.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in ./.local/lib/python3.8/site-packages (from scikit-learn->allennlp) (2.1.0)
Requirement already satisfied: importlib-metadata in ./.local/lib/python3.8/site-packages (from jsonpickle->allennlp) (1.7.0)
Requirement already satisfied: botocore<1.18.0,>=1.17.41 in ./.local/lib/python3.8/site-packages (from boto3->allennlp) (1.17.41)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./.local/lib/python3.8/site-packages (from boto3->allennlp) (0.10.0)
Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in ./.local/lib/python3.8/site-packages (from boto3->allennlp) (0.3.3)
Requirement already satisfied: protobuf>=3.8.0 in ./.local/lib/python3.8/site-packages (from tensorboardX>=1.2->allennlp) (3.12.4)
Requirement already satisfied: pyparsing>=2.0.2 in ./.local/lib/python3.8/site-packages (from packaging->transformers<2.12,>=2.9->allennlp) (2.4.7)
Requirement already satisfied: zipp>=0.5 in ./.local/lib/python3.8/site-packages (from importlib-metadata->jsonpickle->allennlp) (3.1.0)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./.local/lib/python3.8/site-packages (from botocore<1.18.0,>=1.17.41->boto3->allennlp) (2.8.1)
Requirement already satisfied: docutils<0.16,>=0.10 in ./.local/lib/python3.8/site-packages (from botocore<1.18.0,>=1.17.41->boto3->allennlp) (0.15.2)
Requirement already satisfied: urllib3<1.26,>=1.20; python_version != "3.4" in /usr/lib/python3/dist-packages (from botocore<1.18.0,>=1.17.41->boto3->allennlp) (1.25.8)
Building wheels for collected packages: jsonnet
  Building wheel for jsonnet (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gr1p4qce/jsonnet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gr1p4qce/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 /tmp/pip-wheel-n3yamt8b
       cwd: /tmp/pip-install-gr1p4qce/jsonnet/
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_ext
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/desugarer.cpp -o core/desugarer.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/formatter.cpp -o core/formatter.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/libjsonnet.cpp -o core/libjsonnet.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/lexer.cpp -o core/lexer.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/parser.cpp -o core/parser.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/pass.cpp -o core/pass.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/static_analysis.cpp -o core/static_analysis.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/string_utils.cpp -o core/string_utils.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/vm.cpp -o core/vm.o
  g++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json third_party/md5/md5.cpp -o third_party/md5/md5.o
  building '_jsonnet' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/python
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json -I/usr/include/python3.8 -c python/_jsonnet.c -o build/temp.linux-x86_64-3.8/python/_jsonnet.o
  python/_jsonnet.c:20:10: fatal error: Python.h: No such file or directory
     20 | #include <Python.h>
        |          ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for jsonnet
  Running setup.py clean for jsonnet
Failed to build jsonnet
Installing collected packages: jsonnet, allennlp
    Running setup.py install for jsonnet ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gr1p4qce/jsonnet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gr1p4qce/jsonnet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-17wiqf9p/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/tahas/.local/include/python3.8/jsonnet
         cwd: /tmp/pip-install-gr1p4qce/jsonnet/
    Complete output (23 lines):
    running install
    running build
    running build_ext
    make: 'core/desugarer.o' is up to date.
    make: 'core/formatter.o' is up to date.
    make: 'core/libjsonnet.o' is up to date.
    make: 'core/lexer.o' is up to date.
    make: 'core/parser.o' is up to date.
    make: 'core/pass.o' is up to date.
    make: 'core/static_analysis.o' is up to date.
    make: 'core/string_utils.o' is up to date.
    make: 'core/vm.o' is up to date.
    make: 'third_party/md5/md5.o' is up to date.
    building '_jsonnet' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/python
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json -I/usr/include/python3.8 -c python/_jsonnet.c -o build/temp.linux-x86_64-3.8/python/_jsonnet.o
    python/_jsonnet.c:20:10: fatal error: Python.h: No such file or directory
       20 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gr1p4qce/jsonnet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gr1p4qce/jsonnet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-17wiqf9p/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/tahas/.local/include/python3.8/jsonnet Check the logs for full command output.

答案1

查看主题这里

您可以尝试通过以下方式解决此问题:(1)升级到最新版本的 Conda(2)单独jsonnet安装allennlp

conda install -c conda-forge jsonnet进而pip install allennlp

答案2

好的,运行后apt-cache search jsonnet 我意识到我需要的正确包名为 python3-jsonnet。使用安装后,sudo apt-get install python3-jsonnet 我尝试再次安装 allennlp 包,结果成功了。

相关内容