mod-wsgi install時に「ModuleNotFoundError: No module named ‘_ctypes’」
今回はpipでmod-wsgiをインストールしようとしたときに下記のエラーが起きたときの対処法についてご紹介していこうと思います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
Building wheels for collected packages: coreschema, django-rest-auth, jaconv, mod-wsgi Building wheel for coreschema (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-e7kuainr/coreschema_931d2ad02f2542d0b3188b8eed793336/setup.py", line 55, in <module> setup( File "/opt/python3/lib/python3.8/site-packages/setuptools/__init__.py", line 104, in setup return distutils.core.setup(**attrs) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 171, in setup ok = dist.parse_command_line() File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 476, in parse_command_line args = self._parse_command_opts(parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 869, in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 535, in _parse_command_opts cmd_class = self.get_command_class(command) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 714, in get_command_class self.cmdclass[command] = cmdclass = ep.load() File "/opt/python3/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 208, in load module = import_module(match.group('module')) File "/opt/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/root/.local/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 27, in <module> from .macosx_libfile import calculate_macosx_platform_tag File "/root/.local/lib/python3.8/site-packages/wheel/macosx_libfile.py", line 43, in <module> import ctypes File "/opt/python3/lib/python3.8/ctypes/__init__.py", line 7, 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: Failed building wheel for coreschema Running setup.py clean for coreschema Building wheel for django-rest-auth (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-e7kuainr/django-rest-auth_9b77aa0e3bff4f5d80164f4d0eaeb9d0/setup.py", line 13, in <module> setup( File "/opt/python3/lib/python3.8/site-packages/setuptools/__init__.py", line 104, in setup return distutils.core.setup(**attrs) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 171, in setup ok = dist.parse_command_line() File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 476, in parse_command_line args = self._parse_command_opts(parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 869, in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 535, in _parse_command_opts cmd_class = self.get_command_class(command) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 714, in get_command_class self.cmdclass[command] = cmdclass = ep.load() File "/opt/python3/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 208, in load module = import_module(match.group('module')) File "/opt/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/root/.local/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 27, in <module> from .macosx_libfile import calculate_macosx_platform_tag File "/root/.local/lib/python3.8/site-packages/wheel/macosx_libfile.py", line 43, in <module> import ctypes File "/opt/python3/lib/python3.8/ctypes/__init__.py", line 7, 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: Failed building wheel for django-rest-auth Running setup.py clean for django-rest-auth Building wheel for jaconv (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-e7kuainr/jaconv_d037506dd7a34fcd93ec6935f7e4b19d/setup.py", line 11, in <module> setup( File "/opt/python3/lib/python3.8/site-packages/setuptools/__init__.py", line 104, in setup return distutils.core.setup(**attrs) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 171, in setup ok = dist.parse_command_line() File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 476, in parse_command_line args = self._parse_command_opts(parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 869, in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 535, in _parse_command_opts cmd_class = self.get_command_class(command) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 714, in get_command_class self.cmdclass[command] = cmdclass = ep.load() File "/opt/python3/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 208, in load module = import_module(match.group('module')) File "/opt/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/root/.local/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 27, in <module> from .macosx_libfile import calculate_macosx_platform_tag File "/root/.local/lib/python3.8/site-packages/wheel/macosx_libfile.py", line 43, in <module> import ctypes File "/opt/python3/lib/python3.8/ctypes/__init__.py", line 7, 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: Failed building wheel for jaconv Running setup.py clean for jaconv Building wheel for mod-wsgi (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [45 lines of output] WARNING: The Python installation you are using does not appear to have been installed with a shared library, or in the case of MacOS X, as a framework. Where these are not present, the compilation of mod_wsgi may fail, or if it does succeed, will result in extra memory being used by all processes at run time as a result of the static library needing to be loaded in its entirety to every process. It is highly recommended that you reinstall the Python installation being used from source code, supplying the '--enable-shared' option to the 'configure' script when configuring the source code prior to building and installing it. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-e7kuainr/mod-wsgi_8df48f5af39a483dbd4cb1da1672857a/setup.py", line 416, in <module> setup(name = package_name, File "/opt/python3/lib/python3.8/site-packages/setuptools/__init__.py", line 104, in setup return distutils.core.setup(**attrs) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 171, in setup ok = dist.parse_command_line() File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 476, in parse_command_line args = self._parse_command_opts(parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 869, in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) File "/opt/python3/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 535, in _parse_command_opts cmd_class = self.get_command_class(command) File "/opt/python3/lib/python3.8/site-packages/setuptools/dist.py", line 714, in get_command_class self.cmdclass[command] = cmdclass = ep.load() File "/opt/python3/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 208, in load module = import_module(match.group('module')) File "/opt/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/root/.local/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 27, in <module> from .macosx_libfile import calculate_macosx_platform_tag File "/root/.local/lib/python3.8/site-packages/wheel/macosx_libfile.py", line 43, in <module> import ctypes File "/opt/python3/lib/python3.8/ctypes/__init__.py", line 7, 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: Failed building wheel for mod-wsgi Running setup.py clean for mod-wsgi Failed to build coreschema django-rest-auth jaconv mod-wsgi ERROR: Could not build wheels for coreschema, django-rest-auth, jaconv, mod-wsgi, which is required to install pyproject.toml-based projects |
動作環境はPython3.8.13で、RHEL系のLinuxディストリビューションであるAlmaLinux9.3を使用しております。
mod-wsgi install時に「ModuleNotFoundError: No module named '_ctypes’」
結論から言うとlibffi-develをインストールしてから再度Pythonをインストールすると冒頭のエラーは出なくなります。
1 |
dnf install libffi-devel |
してから再度Pythonを入れ直します。
Pythonを入れ直すとなると手間がかかりますが、これで直ると思って頑張りましょう。
終わりに
今回はpipでmod-wsgiをインストールしようとしたときに冒頭のエラーが起きたときの対処法についてご紹介させていただきました。
ディスカッション
コメント一覧
まだ、コメントがありません