Tried to use

sudo apt-get install python3.5

and it's telling me that it can't find it. Have tried updating. Not sure what else to do.

  • 1
    What version of Raspbian are you using? What model Pi? How is the Pi connected to the internet? What is the specific error code? We are going to need more information, currently you question is very, very vague. – Darth Vader Sep 2 '16 at 7:44

I tried installing the python3.5.2 with the below steps and I was successful.

1. wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
2. tar -xvf Python-3.5.2.tar.xz
3. cd Python-3.5.2
4. ./configure
5. make
6 make altinstall

Once the installation is completed use which python3.5 command to get the binary location

In my case it was installed in the location /usr/local/bin/python3.5.

To get into the REPL of 3.5 type python3.5 on your terminal. The existing python distribution remains intact without issues. Verify that using the python. I have tried installing python 3.4 and 3.5 versions.

pi@raspberrypi:/etc/openhab/configurations $ python -V
Python 2.7.9
pi@raspberrypi:/etc/openhab/configurations $ python3.5 -V
Python 3.5.2
pi@raspberrypi:/etc/openhab/configurations $ python3.4 -V
Python 3.4.2

Also as time permits I suggest you to read the article https://stackoverflow.com/questions/16018463/difference-in-details-between-make-install-and-make-altinstall.

It should work. The only issue while i faced during installation is the time taken for the whole process. It took almost 3 hours because a lot of time is consumed in compiling the binaries and then installing python.

| improve this answer | |
  • 2
    You can speed things up by using more threads with make -j4. Possibly even using -j6. – not2qubit Oct 22 '16 at 0:47

First of all you need to get your dependencies right. That mostly depend on what you have already installed previously. So for a vanilla fresh Raspbian (jessie), you will (approximately) need to make sure you have these:

sudo apt-get install build-essential libc6-dev
sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev

The rest is simple. First download and extract...

cd $HOME
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar -zxvf Python-3.5.2.tgz

...and then compile with:

cd Python-3.5.2
./configure       # 3 min 13 s
# We have 4 processors, so let's use 4 threads
make -j4          # 8 min 29 s
sudo make install # ~ 4 min

Save your SD card space:

cd ..
sudo rm -fr ./Python-3.5.2*

Now test with:

python3 --version
# output: "Python 3.5.2"
pip3 list
# output: 
# pip (8.1.1)
# setuptools (20.10.1)
# You are using pip version 8.1.1, however version 8.1.2 is available.
# You should consider upgrading via the 'pip install --upgrade pip' command.

Update your default pip installation with:

sudo pip3 install -U pip
sudo pip3 install -U setuptools


| improve this answer | |
  • 1
    This is great! Many thanks. Now, there are a newer versions of python. Check python.org for latest. – smajli Apr 11 '18 at 8:31
  • Yes, replace all 3.5.2 with 3.7.0. And you should have the latest! – not2qubit Jul 2 '18 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.