10

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
  • 192
  • 2
  • 2
  • 11

2 Answers2

19
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
Undo
  • 25,519
  • 37
  • 106
  • 129
RaviTezu
  • 3,047
  • 19
  • 26
  • 2
    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 :) – Robert Vasistha May 07 '16 at 11:02
  • Did you try `python3 --version` ? – RaviTezu May 07 '16 at 18:34
  • 1
    @robert You may need to restart. – yrg Sep 09 '16 at 03:09
  • 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. – Robert Feb 13 '17 at 20:40
  • In case anyone was wondering how to accomplish what @Robert was suggesting: There's the [checkinstall](https://help.ubuntu.com/community/CheckInstall) package which accomplishes something similar. Just replace `sudo make install` with `sudo checkinstall` and you're good to go. – heyarne Mar 05 '18 at 10:27
7

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!

Community
  • 1
  • 1
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
  • My dependencies were already up to date and when I tried to download the source this happened: pi@raspberrypi:~ $ tar -xzvf https://www.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 https://www.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 May 07 '16 at 10:33
  • For more details, check [my answer here](http://raspberrypi.stackexchange.com/a/56632/17798). – not2qubit Oct 22 '16 at 01:17