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

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

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

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

Q&A

解決済

1回答

3144閲覧

python3でなぜかインストールできないモジュールがある

yum_sum

総合スコア2

Python

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

0グッド

0クリップ

投稿2021/01/31 07:57

編集2021/06/10 04:00

前提・実現したいこと

python3でevdevと依存関係にあるpynputというモジュールをインストールしようとしているのですが、インストール中にエラーが起きてしまいます。エラーメッセージを見てもいまいち解決策がわからなかったので、わかる方がいれば教えていただけると幸いです。

実行環境

実行環境はiPhone11で、Alpine_LinuxベースのiSHというアプリを使ってターミナルを利用しています。
エラーメッセージ中に「linux-i686-3.8のライブラリのビルドが~」と表示されていたので、iOSでLinuxのターミナルを利用しているのが原因なのかと個人的には思っています。

該当のソースコード

ash

1$ python3 -m pip install pynput

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

全文を載せているのでかなり長いです。

Collecting pynput Downloading pynput-1.7.2-py2.py3-none-any.whl (99 kB) |███▎ | 10 kB 640 |██████▋ | 20 kB 748 |█████████▉ | 30 kB 801 |█████████████▏ | 40 kB 822 |████████████████▌ | 51 kB 854 |███████████████████▊ | 61 kB 853 |███████████████████████ | 71 kB 866 |██████████████████████████▍ | 81 kB 887 |█████████████████████████████▋ | 92 kB 897 |████████████████████████████████| 99 kB 608 kB/s Collecting evdev>=1.3 Downloading evdev-1.4.0.tar.gz (26 kB) Requirement already satisfied: python-xlib>=0.17 in /usr/lib/python3.8/site-packages (from pynput) (0.29) Requirement already satisfied: six in /usr/lib/python3.8/site-packages (from pynput) (1.15.0) Building wheels for collected packages: evdev Building wheel for evdev (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-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/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-iyq0a8w2 cwd: /tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/ Complete output (37 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-i686-3.8 creating build/lib.linux-i686-3.8/evdev copying evdev/ff.py -> build/lib.linux-i686-3.8/evdev copying evdev/evtest.py -> build/lib.linux-i686-3.8/evdev copying evdev/device.py -> build/lib.linux-i686-3.8/evdev copying evdev/util.py -> build/lib.linux-i686-3.8/evdev copying evdev/events.py -> build/lib.linux-i686-3.8/evdev copying evdev/ecodes.py -> build/lib.linux-i686-3.8/evdev copying evdev/__init__.py -> build/lib.linux-i686-3.8/evdev copying evdev/uinput.py -> build/lib.linux-i686-3.8/evdev copying evdev/genecodes.py -> build/lib.linux-i686-3.8/evdev copying evdev/eventio.py -> build/lib.linux-i686-3.8/evdev copying evdev/eventio_async.py -> build/lib.linux-i686-3.8/evdev running build_ext running build_ecodes The 'linux/input.h' and 'linux/input-event-codes.h' include files are missing. You will have to install the kernel header files in order to continue: yum install kernel-headers-$(uname -r) apt-get install linux-headers-$(uname -r) emerge sys-kernel/linux-headers pacman -S kernel-headers In case they are installed in a non-standard location, you may use the '--evdev-headers' option to specify one or more colon-separated paths. For example: python setup.py \ build \ build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \ build_ext --include-dirs path/ \ install ---------------------------------------- ERROR: Failed building wheel for evdev Running setup.py clean for evdev Failed to build evdev Installing collected packages: evdev, pynput Running setup.py install for evdev ... 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-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/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-bwtzdavm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/evdev cwd: /tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/ Complete output (37 lines): running install running build running build_py creating build creating build/lib.linux-i686-3.8 creating build/lib.linux-i686-3.8/evdev copying evdev/ff.py -> build/lib.linux-i686-3.8/evdev copying evdev/evtest.py -> build/lib.linux-i686-3.8/evdev copying evdev/device.py -> build/lib.linux-i686-3.8/evdev copying evdev/util.py -> build/lib.linux-i686-3.8/evdev copying evdev/events.py -> build/lib.linux-i686-3.8/evdev copying evdev/ecodes.py -> build/lib.linux-i686-3.8/evdev copying evdev/__init__.py -> build/lib.linux-i686-3.8/evdev copying evdev/uinput.py -> build/lib.linux-i686-3.8/evdev copying evdev/genecodes.py -> build/lib.linux-i686-3.8/evdev copying evdev/eventio.py -> build/lib.linux-i686-3.8/evdev copying evdev/eventio_async.py -> build/lib.linux-i686-3.8/evdev running build_ext running build_ecodes The 'linux/input.h' and 'linux/input-event-codes.h' include files are missing. You will have to install the kernel header files in order to continue: yum install kernel-headers-$(uname -r) apt-get install linux-headers-$(uname -r) emerge sys-kernel/linux-headers pacman -S kernel-headers In case they are installed in a non-standard location, you may use the '--evdev-headers' option to specify one or more colon-separated paths. For example: python setup.py \ build \ build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \ build_ext --include-dirs path/ \ install ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7sqik1mu/evdev_fc21af52a1e24f988a8bb73ecabec919/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-bwtzdavm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/evdev Check the logs for full command output.

試したこと

試してみたこと一覧です

  • wheel(パッケージ管理システム)のインストール
  • gccのインストール
  • alpine-sdk(build-essential)のインストール
  • キャッシュの削除

ちなみにpytubeはインストールできたので、pip自体に問題があるわけではなさそうです。

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

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

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

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

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

68user

2021/01/31 08:13

yum install kernel-headers-$(uname -r) 以降をやらないのは意図してそうしているのですか? (iPhone11 だから yum がない?)
yum_sum

2021/01/31 08:28

ご指摘の通り、yumがないです。代わりにapkというパッケージ管理システムがあるのですが、多分そちらにはないだろうなと勝手に思い込んでインストールしてませんでした。 よく考えてみれば、apkにkernel-headersがなくとも最悪ソースコードからなんなりできそうなので今からちょっと頑張ってきます。ご指摘ありがとうございます。
jbpb0

2021/01/31 08:35

> Building wheel for evdev (setup.py) ... error > ERROR: Failed building wheel for evdev > Running setup.py install for evdev ... error エラーは、pynputのインストールではなく、evdevのインストールですね > The 'linux/input.h' and 'linux/input-event-codes.h' include files are missing. がエラーの原因なので、ヘッダーを追加インストールしろと言ってますね > You will have to install the kernel header files in order to continue: (以下略)
68user

2021/01/31 08:46

一応一般論として。 pip から入れるとビルドが必要ですが、yum・apt-get 等の OS 側パッケージだと python-evdev・py-evdev・py3.8-evdev などの名前でビルド済パッケージがあるのでさくっと入ると思われます。apk のリポジトリにある、またビルド済のバイナリとアーキテクチャが同じであることが必要ですけれども。
guest

回答1

0

自己解決

apkにlinux-headerがあったので、apkからインストールしてpynputを再インストールしたところ、

evdev/input.c:10:10: fatal error: Python.h: No such file or directory 10 | #include <Python.h> | ^~~~~~~~~~ compilation terminated. error: command 'gcc' failed with exit status 1 ----------------------------------------

と表示されたのでpython3-devを入れて再挑戦し、無事pynputをインストールすることができました!
私一人では到底無理でした。ご指摘くださり本当にありがとうございます。

投稿2021/01/31 09:23

yum_sum

総合スコア2

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問