[PYTHON] No module named'_ctypes' occurs when installing pipenv

environment

OS: Amazon Linux 2 Python: 3.8.1

Event

After installing python3.8.1 with pyenv, when I execute pip install pipenv, the following error occurs and I cannot install it.

    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.

Workaround

Solved below

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

In this state

pip install pipenv

You can install it!

Recommended Posts

No module named'_ctypes' occurs when installing pipenv
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
Error when installing opencv-python on jetson nano (ModuleNotFoundError: No module named'skbuild')
When lambda-uploader says No module named xxxx.
ModuleNotFoundError: No module named'***' when running Flask
Error when installing a module with Python pip
ModuleNotFoundError: No module named'py4j'
Stumbled when installing PyOCR
ModuleNotFoundError: No module named'flask_sqlalchemy'
After installing CentOS8 with VirtualBox, an error occurs when restarting
After installing pygame with conda install No module named font
ImportError: No module What to do when you are told
Defense notes when pip3 doesn't work with "ImportError: No module named'packaging'" after installing python3-pip on Debian8