How do you update to the latest python 3.5.1 version on a raspberry pi?

19,988

Solution 1

cd ~
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar -zxvf Python-3.5.1.tgz
cd Python-3.5.1
./configure && make && sudo make install

Solution 2

I would compile it myself (and indeed, have a few times). I'm assuming that you're running Ubuntu or Raspbian. You should be able to install the dependencies:

$ sudo apt-get install build-essential \
                       libncursesw5-dev \
                       libreadline5-dev \
                       libssl-dev \
                       libgdbm-dev \
                       libc6-dev \
                       libsqlite3-dev tk-dev \
                       libbz2-dev

Then go download the source and extract it, and then install it:

  $ tar -xzvf https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
  $ cd Python-3.5.1
  $ ./configure && make && sudo make install

If you're missing a dependency it will probably die at the ./configure step. But if everything works, you'll have a brand new Python 3.5 install on your Raspberry Pi. Congrats!

Share:
19,988
Robert Vasistha
Author by

Robert Vasistha

Updated on June 12, 2022

Comments

  • Robert Vasistha
    Robert Vasistha almost 2 years

    I got my Raspberry Pi yesterday and I am already trying to code with it. I have a program that I was planning to run on it but it is only compatible with Python versions 3.5.0 or 3.5.1 and everything I find on the internet seems to either be outdated, to do with Python 2 or doesn't relate to my problem as I haven't seen anything else that 100% requires Python 3.5 and can cope with 3.4(currently pre-installed). .exe files don't work on Linux. I am new to the Raspberry Pi and with Linux as I have always been a Windows user. Any help is appreciated. Many Thanks - Robert

  • Robert Vasistha
    Robert Vasistha about 8 years
    My dependencies were already up to date and when I tried to download the source this happened: pi@raspberrypi:~ $ tar -xzvf python.org/ftp/python/3.5.1/Python-3.5.1.tgz tar (child): Cannot connect to https: resolve failed gzip: stdin: unexpected end of file tar: Child returned status 128 tar: Error is not recoverable: exiting now pi@raspberrypi:~ $ tar -xzvf python.org/ftp/python/3.5.1/Python-3.5.1.tgz tar (child): Cannot connect to https: resolve failed gzip: stdin: unexpected end of file tar: Child returned status 128 tar: Error is not recoverable: exiting now
  • Robert Vasistha
    Robert Vasistha about 8 years
    I followed your steps and I think it worked but now how do I open 3.5? I have tried opening the python 3 idle in the programming bar in the top right but it still opens 3.4.2 o,0. Thanks for the reply :)
  • RaviTezu
    RaviTezu about 8 years
    Did you try python3 --version ?
  • yrg
    yrg over 7 years
    @robert You may need to restart.
  • not2qubit
    not2qubit over 7 years
    For more details, check my answer here.
  • Robert
    Robert over 7 years
    Wouldn't it be better to create a deb package and install that? Directly calling make install is a good way to mess up your system.
  • heyarne
    heyarne about 6 years
    In case anyone was wondering how to accomplish what @Robert was suggesting: There's the checkinstall package which accomplishes something similar. Just replace sudo make install with sudo checkinstall and you're good to go.