Ошибки при установке NLTK - PullRequest
0 голосов
/ 27 мая 2020

при попытке установить NLTK с помощью pip install nltk я получил следующую ошибку


  ----------------------------------------
  Failed building wheel for nltk
  Running setup.py clean for nltk
  Running setup.py bdist_wheel for regex ... error
  Complete output from command /home/pavan/Desktop/chatbot/myenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s1j858so/regex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp01krw6rjpip-wheel- --python-tag cp35:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for regex
  Running setup.py clean for regex
Failed to build nltk regex
Installing collected packages: regex, tqdm, nltk
  Running setup.py install for regex ... error
    Complete output from command /home/pavan/Desktop/chatbot/myenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s1j858so/regex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5loncafz-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pavan/Desktop/chatbot/myenv/include/site/python3.5/regex:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/regex
    copying regex_3/__init__.py -> build/lib.linux-x86_64-3.5/regex
    copying regex_3/regex.py -> build/lib.linux-x86_64-3.5/regex
    copying regex_3/_regex_core.py -> build/lib.linux-x86_64-3.5/regex
    copying regex_3/test_regex.py -> build/lib.linux-x86_64-3.5/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/regex_3
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/pavan/Desktop/chatbot/myenv/include -I/usr/include/python3.5m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.5/regex_3/_regex.o
    regex_3/_regex.c:48:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/home/pavan/Desktop/chatbot/myenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s1j858so/regex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5loncafz-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pavan/Desktop/chatbot/myenv/include/site/python3.5/regex" failed with error code 1 in /tmp/pip-build-s1j858so/regex/
You are using pip version 8.1.1, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Чтобы устранить ошибку error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 я попробовал sudo apt-get install python3-dev, как показано в другом сообщении stackOverflow, но получил ошибку

E: Malformed entry 4 in list file /etc/apt/sources.list.d/additional-repositories.list (Component)
E: The list of sources could not be read.
E: Malformed entry 4 in list file /etc/apt/sources.list.d/additional-repositories.list (Component)
E: The list of sources could not be read.

Может кто-нибудь объяснить, что пошло не так и что такое ошибка g cc?

PS: - Я установил virtualenv с помощью python3 -m venv myenv

1 Ответ

0 голосов
/ 28 мая 2020

Я думаю, что решение кроется в ошибке, поскольку в ней говорится, что:

Command "/home/pavan/Desktop/chatbot/myenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s1j858so/regex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5loncafz-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pavan/Desktop/chatbot/myenv/include/site/python3.5/regex" failed with error code 1 in /tmp/pip-build-s1j858so/regex/
You are using pip version 8.1.1, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Итак, вы используете версию 8.1.1, которая слишком старая, поскольку текущая версия 20.1.1 . Итак, обновление pip с помощью следующей команды решит вашу проблему:

pip install --upgrade pip
...