2

I am trying to install Python 3.7.1 so I wont break the system, but pyenv always get error. I installed pyenv per this link:How do I install Python 3.6 using apt-get?

Where it says install pyenv and it seems to work, but fails to install Python3.7.1

Can someone please help me? what is the next step to find the problem?

$ pyenv install 3.7.1

    Downloading Python-3.7.1.tar.xz...
    -> https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
    Installing Python-3.7.1...

    BUILD FAILED (Ubuntu 18.04 using python-build 1.2.8)

    Inspect or clean up the working tree at /tmp/python-build.20181117140343.4690
    Results logged to /tmp/python-build.20181117140343.4690.log

    Last 10 log lines:
      File "/tmp/tmpgu4s65ck/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/__init__.py", line 42, in 
      File "/tmp/tmpgu4s65ck/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/cmdoptions.py", line 16, in 
      File "/tmp/tmpgu4s65ck/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/index.py", line 25, in 
      File "/tmp/tmpgu4s65ck/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py", line 39, in 
      File "/tmp/tmpgu4s65ck/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in 
      File "/tmp/python-build.20181117140343.4690/Python-3.7.1/Lib/ctypes/__init__.py", line 7, in 
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
    Makefile:1122: recipe for target 'install' failed
    make: *** [install] Error 1
karel
  • 122,292
  • 133
  • 301
  • 332

2 Answers2

4

install missing build tools

sudo apt-get install build-essential git libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev libffi-dev

then install python 3.7.1 via pyenv

pyenv install 3.7.1

not to be cocky, but you're probably just missing libffi-dev

0

The issue is likely a missing installation of libffi-dev which can be installed with:

sudo apt install libffi-dev

Note: You may need to re-install python to get this to work. In my case, It would not stick until I un-installed and then re-installed Python.