ModuleNotFoundError: No module named '_ctypes' in Python

Dung Do Tien Aug 13 2021 1091

Hi Guys,

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

 ERROR: Command errored out with exit status 1:
     command: /python_root/.pyenv/versions/3.8.1/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-shwfwhga/distlib/'"'"'; __file__='"'"'/tmp/pip-install-shwfwhga/distlib/'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);'"'"'\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 "/python_root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/", line 20, in <module>
        from setuptools.dist import Distribution, Feature
      File "/python_root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/", line 35, in <module>
        from setuptools import windows_support
      File "/python_root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/setuptools/", line 2, in <module>
        import ctypes
      File "/python_root/.pyenv/versions/3.8.1/lib/python3.8/ctypes/", line 7, in <module>
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
ERROR: Command errored out with exit status 1: python egg_info Check the logs for full command output.

Please help me how can I resolve this issue?

Have 1 answer(s) found.
  • T

    Trọng Hiếu Aug 13 2021

    You can solve that issue by follow run command below:

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

    And it work for me.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close