LoginSignup
9

More than 3 years have passed since last update.

pipenvのinstall時に、No module named '_ctypes'が発生する

Posted at

環境

OS:
Amazon Linux 2
Python:
3.8.1

事象

pyenvでpython3.8.1をinstall後、pip install pipenvを実行すると以下のエラーが発生し、installできない。

    ERROR: Command errored out with exit status 1:
     command: /root/.pyenv/versions/3.8.1/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-shwfwhga/distlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-shwfwhga/distlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-shwfwhga/distlib/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <module>
        from setuptools.dist import Distribution, Feature
      File "/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/dist.py", line 35, in <module>
        from setuptools import windows_support
      File "/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes
      File "/root/.pyenv/versions/3.8.1/lib/python3.8/ctypes/__init__.py", line 7, in <module>
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

対処方法

以下で解決

pyenv uninstall 3.8.1
sudo yum install libffi-devel
pyenv install 3.8.1

この状態で

pip install pipenv

すればinstallできます!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
9