【发布时间】:2020-05-27 10:31:18
【问题描述】:
在尝试通过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
【问题讨论】:
-
运行
pip install --update pip -
@Anwarvic 更新后 pip 。错误减少了,现在的错误是
Requirement already satisfied: joblib in ./myenv/lib/python3.5/site-packages (from nltk) (0.15.1) ERROR: Package 'joblib' requires a different Python: 3.5.2 not in '>=3.6'我正在使用python 3.5.2 -
@Anwarvic 你能解释一下 gcc 错误以及为什么升级 pip 解决了它
-
我已经在下面解释了这个问题。
标签: python linux pip nltk gcc-warning