安装NLTK时出现错误

问题描述 投票:0回答:1

[尝试通过pip install nltk安装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.

有人可以解释出什么问题了,什么是gcc错误?

P.S:-我通过python3 -m venv myenv 安装了virtualenv

python linux pip nltk gcc-warning
1个回答
0
投票

我认为解决方案在于错误,因为它指出:

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
© www.soinside.com 2019 - 2024. All rights reserved.