質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

Q&A

解決済

1回答

856閲覧

pip2でnltkをインストールする方法を教えて下さい

fen57

総合スコア47

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

0グッド

0クリップ

投稿2020/12/16 22:15

前提・実現したいこと

pip2でのnltkインストール中に以下のエラーが発生し、インストールに失敗しました。

発生している問題・エラーメッセージ

Processing /root/.cache/pip/wheels/c7/b1/76/54236c34227a12d32dc9cfe18731976baf8950d8a5aabaea6c/nltk-3.5-py2-none-any.whl Requirement already satisfied: click in /usr/local/lib/python2.7/dist-packages (from nltk) (7.1.2) Requirement already satisfied: tqdm in /usr/local/lib/python2.7/dist-packages (from nltk) (4.54.1) Requirement already satisfied: joblib in /usr/local/lib/python2.7/dist-packages (from nltk) (0.14.1) Collecting regex Using cached regex-2020.11.13.tar.gz (694 kB) Building wheels for collected packages: regex Building wheel for regex (setup.py) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-S2hLKa/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-S2hLKa/regex/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-2P6E6l cwd: /tmp/pip-install-S2hLKa/regex/ Complete output (20 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-2.7 creating build/lib.linux-x86_64-2.7/regex copying regex_2/__init__.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/regex.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/_regex_core.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/test_regex.py -> build/lib.linux-x86_64-2.7/regex running build_ext building 'regex._regex' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/regex_2 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-uC7NI8/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o regex_2/_regex.c:50:10: fatal error: Python.h: そのようなファイルやディ レクトリはありません 50 | #include "Python.h" | ^~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for regex Running setup.py clean for regex Failed to build regex Installing collected packages: regex, nltk Running setup.py install for regex ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-S2hLKa/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-S2hLKa/regex/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-Z_CIMI/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/regex cwd: /tmp/pip-install-S2hLKa/regex/ Complete output (20 lines): running install running build running build_py creating build creating build/lib.linux-x86_64-2.7 creating build/lib.linux-x86_64-2.7/regex copying regex_2/__init__.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/regex.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/_regex_core.py -> build/lib.linux-x86_64-2.7/regex copying regex_2/test_regex.py -> build/lib.linux-x86_64-2.7/regex running build_ext building 'regex._regex' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/regex_2 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-uC7NI8/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o regex_2/_regex.c:50:10: fatal error: Python.h: そのようなファイルやデ ィレクトリはありません 50 | #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/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-S2hLKa/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-S2hLKa/regex/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-Z_CIMI/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/regex Check the logs for full command output.

試したこと

nltk pip2 failed などで検索しましたが、解決できそうな情報が得られず困っています。
どなたかご教授お願いいたします。

補足情報(FW/ツールのバージョンなど)

Kali Linux 2020.2
Python 2.7.18
pip2 20.3.3

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

C言語で書かれたソースファイルをコンパイルする必要があるモジュールなので、コンパイルに必要なヘッダーファイル(Python.hなど)が含まれるKali linuxのパッケージ(python2-dev)をインストールしてください。

sudo apt install python2-dev

投稿2020/12/16 22:53

Daregada

総合スコア11990

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

fen57

2020/12/16 23:02

ありがとうございます。解決しました
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問