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
  • 114,770
  • not to solve specific problem but to give you python3.7.1, just use anaconda link – sleepyhead Nov 18 '18 at 12:50
  • Hi, Sorry about the edit issue, I got it solved pyenv did not install libffi-dev, so I sudo apt-get install libffi-dev pyenv works Great now and installed Python 3.71 and 3.6.7 also – STKEX-Taz Nov 19 '18 at 00:53
  • could you please change the title to "ubuntu linux library install python pyenv" (optionally add "prerequisites") --- Maybe also add some more tags, too. --- The solution by @chris-dare works for 22.04 with 3.10.9 , so the versions in the title are noise not signal! – Summer-Sky Sep 25 '23 at 18:38

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.

Timothy C. Quinn
  • 1,213
  • 1
  • 14
  • 22