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

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

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

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

pip

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

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

Q&A

解決済

1回答

1744閲覧

Seleniumがインストールできない(_ctypesがない)

floater

総合スコア1

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

pip

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

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

0グッド

0クリップ

投稿2022/08/12 07:54

前提

Rasberry Pi 4 Bモデル
Python 3.10.3
Pyenv

実現したいこと

PythonモジュールSeleniumをインストールしたい

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

下記のエラーにより先に進めません。

Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting selenium Using cached selenium-4.4.0-py3-none-any.whl (985 kB) Collecting urllib3[secure,socks]~=1.26 Using cached https://www.piwheels.org/simple/urllib3/urllib3-1.26.11-py2.py3-none-any.whl (139 kB) Collecting trio~=0.17 Using cached https://www.piwheels.org/simple/trio/trio-0.21.0-py3-none-any.whl (358 kB) Collecting trio-websocket~=0.9 Using cached https://www.piwheels.org/simple/trio-websocket/trio_websocket-0.9.2-py3-none-any.whl (16 kB) Requirement already satisfied: async-generator>=1.9 in ./.local/lib/python3.10/site-packages (from trio~=0.17->selenium) (1.10) Collecting idna Using cached https://www.piwheels.org/simple/idna/idna-3.3-py3-none-any.whl (64 kB) Requirement already satisfied: sortedcontainers in ./.local/lib/python3.10/site-packages (from trio~=0.17->selenium) (2.4.0) Collecting outcome Using cached https://www.piwheels.org/simple/outcome/outcome-1.2.0-py2.py3-none-any.whl (9.7 kB) Requirement already satisfied: sniffio in ./.local/lib/python3.10/site-packages (from trio~=0.17->selenium) (1.2.0) Requirement already satisfied: attrs>=19.2.0 in ./.local/lib/python3.10/site-packages (from trio~=0.17->selenium) (22.1.0) Requirement already satisfied: wsproto>=0.14 in ./.local/lib/python3.10/site-packages (from trio-websocket~=0.9->selenium) (1.1.0) Collecting cryptography>=1.3.4 Using cached cryptography-37.0.4.tar.gz (585 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. x exit code: 1 mq> [96 lines of output] running dist_info creating /tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info writing /tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/PKG-INFO writing dependency_links to /tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/dependency_links.txt writing requirements to /tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/requires.txt writing top-level names to /tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/top_level.txt writing manifest file '/tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'docs/_build' warning: no previously-included files found matching 'vectors' warning: no previously-included files matching '*' found under directory 'vectors' warning: no previously-included files matching '*' found under directory '.github' warning: no previously-included files found matching 'release.py' warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching 'codecov.yml' warning: no previously-included files found matching '.readthedocs.yml' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'mypy.ini' warning: no previously-included files matching '*' found under directory '.circleci' adding license file 'LICENSE' adding license file 'LICENSE.APACHE' adding license file 'LICENSE.BSD' adding license file 'LICENSE.PSF' writing manifest file '/tmp/pip-modern-metadata-r0vbqxhx/cryptography.egg-info/SOURCES.txt' creating '/tmp/pip-modern-metadata-r0vbqxhx/cryptography-37.0.4.dist-info' =============================DEBUG ASSISTANCE============================= If you are seeing a compilation error please try the following steps to successfully install cryptography: 1) Upgrade to the latest pip and try again. This will fix errors for most users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip 2) Read https://cryptography.io/en/latest/installation/ for specific instructions for your platform. 3) Check our frequently asked questions for more information: https://cryptography.io/en/latest/faq/ 4) Ensure you have a recent Rust toolchain installed: https://cryptography.io/en/latest/installation/#rust Python: 3.10.3 platform: Linux-5.15.32-v7l+-armv7l-with-glibc2.31 pip: n/a setuptools: 64.0.1 setuptools_rust: 1.5.0 =============================DEBUG ASSISTANCE============================= Traceback (most recent call last): File "/home/hyugo/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module> main() File "/home/hyugo/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/home/hyugo/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 369, in prepare_metadata_for_build_wheel self.run_setup() File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in run_setup exec(code, locals()) File "<string>", line 39, in <module> File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup return distutils.core.setup(**attrs) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands self.run_command(cmd) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command super().run_command(command) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command cmd_obj.run() File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/command/dist_info.py", line 101, in run bdist_wheel = self.get_finalized_command('bdist_wheel') File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 305, in get_finalized_command cmd_obj = self.distribution.get_command_obj(command, create) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 864, in get_command_obj klass = self.get_command_class(command) File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 954, in get_command_class self.cmdclass[command] = cmdclass = ep.load() File "/usr/local/lib/python3.10/importlib/metadata/__init__.py", line 171, in load module = import_module(match.group('module')) File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 26, in <module> from .macosx_libfile import calculate_macosx_platform_tag File "/tmp/pip-build-env-0fovon24/overlay/lib/python3.10/site-packages/wheel/macosx_libfile.py", line 41, in <module> import ctypes File "/usr/local/lib/python3.10/ctypes/__init__.py", line 8, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. mq> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.

該当のソースコード

python3 -m pip install selenium

試したこと

Pythonの再インストール
libffi のインストール

解決策や原因のご教示お願い致します。

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

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

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

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

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

quickquip

2022/08/12 08:38

メッセージからはpyenvを使っている雰囲気は感じられません。 OSがなにか、 pyenv versions which python pyenv which python あたりの結果を質問を編集して載せるといいかもしれません。 あとpyenvのインストール方法を見直してみてはどうでしょう。 https://github.com/pyenv/pyenv https://github.com/pyenv/pyenv/wiki#suggested-build-environment と書いたところで、pyenvが対応しているOSを使っているのか疑問になってきました。
guest

回答1

0

ベストアンサー

https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul

python自身にffiの機能を持たせてビルドしていないことが原因と考えられます。
libffi だけでなく、 libffi-dev パッケージをインストールしたうえで再度Pythonのビルド(インストール)を試してみてください。

投稿2022/08/12 08:05

kazto

総合スコア7196

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

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

floater

2022/08/12 08:09

ご回答ありがとうございます。 raspberrypi:~$ sudo apt-get install libffi-dev パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています... 完了 状態情報を読み取っています... 完了 libffi-dev はすでに最新バージョン (3.3-6) です。 既にlibffiはインストール済みです。
kazto

2022/08/12 08:12

インストール済みでしたか。ということは次に、Pythonのビルド時にうまく当たっていないことが考えられます。 Pythonのビルドはどのように行いましたか?
floater

2022/08/12 08:13

pyenvを用いて行いました。 具体的に pyenv install 3.10.3 このコマンドのみ実行しました。
kazto

2022/08/12 08:17

https://qiita.com/kentac55/items/6881725c8e6343bd8965 上記の記事はLinuxが別のディストリビューションで、インストール先は参考にならないんですが、pyenv install 時に環境変数 LDFLAGS、CFLAGS でライブラリやヘッダのありかを明示してやる必要がありそうです。
floater

2022/08/12 08:36

ありがとうございます。試してみます。
quickquip

2022/08/13 01:57

「ヘッダファイルが変なところに置かれた場合」の対処方法がなにかの参考になりましたか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問