I have a Raspberry pi 3 Model B and I want to install Python 3.6 on it.

A bit of context:

  • I acquired this Raspberry pi over 2 years ago and it came with Python 2.7 and 3.4 installed by default in /usr/bin/.

  • To install Python 3.6, I used the following instructions:


Briefly, the commands in that link are:

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

$ wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz

$ sudo tar zxf Python-3.6.8.tgz
$ cd Python-3.6.8
$ ./configure
$ make -j 4
$ make altinstall

I tried following theses instructions but:

1) I made a directory in my home into which I downloaded the .tgz file. In other words, before the wget command, I did:

$ cd
$ mkdir my-packages/my-python3.6 && cd /my-packages/my-python3.6

I don't think this changes anything but in any case, I thought I should say it.

2) All was well but when doing the ./configure command and the following 2, I was shown a permission denied. Unfortunately I don't have the exact error messages for all 3 commands (the output was so big I can't go back) but I do have it for the "make -j 4" command:

Assembler messages:
Fatal error: can't create Parser/grammar1.o: Permission denied
Makefile:1589: recipe for target 'Parser/grammar1.o' failed
make: *** [Parser/grammar1.o] Error 1
make: *** Waiting for unfinished jobs....
Assembler messages:
Fatal error: can't create Programs/python.o: Permission denied
Makefile:766: recipe for target 'Programs/python.o' failed
make: *** [Programs/python.o] Error 1
Assembler messages:
Fatal error: can't create Parser/acceler.o: Permission denied
Makefile:1589: recipe for target 'Parser/acceler.o' failed
make: *** [Parser/acceler.o] Error 1
Assembler messages:
Fatal error: can't create Parser/listnode.o: Permission denied
Makefile:1589: recipe for target 'Parser/listnode.o' failed
make: *** [Parser/listnode.o] Error 1

When I used "sudo" in front of all 3 commands, it seems to work.

So my question is: Why did I need to use sudo for all 3 commands? I have not found any tutorial saying this. Maybe I'm overthinking this but I find it weird to have needed sudo when no else seemed to. Could I have done something wrong?

Also, is it common for a Python installed from source to go to /usr/local/bin?

My sudo rights are:

$ sudo -l

# Output:
Matching Defaults entries for pi on raspberrypi:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User pi may run the following commands on raspberrypi:
    (ALL : ALL) ALL


  • 3
    Why not just download a recent Raspbian? That comes with Python 3.7.3. Presumably you need root permission to write to the directories showing an error. Since you haven't told us where those directories are it's a bit pointless commenting further.
    – joan
    Oct 21, 2019 at 10:40
  • I guess so, but I was hoping to just download 3.6 rather than spend time upgrading my OS. To answer your second point, Python 3.6 was installed in /usr/local/bin. I am just confused as to why I needed sudo rights to write to there.
    – mf94
    Oct 21, 2019 at 10:43
  • Each distribution will have its own rules about where to put various classes of software. Debian/Raspbian chooses /usr/local/bin for user installed software which is to be accesisble to all users. /usr is owned by root. /usr/local is owned by root. /usr/local/bin is owned by root. So you need root permissions.
    – joan
    Oct 21, 2019 at 10:52
  • Ok so I guess its all ok. Thanks!
    – mf94
    Oct 21, 2019 at 11:05

2 Answers 2


To answer your permissions/folder question: you need root permissions for /usr/local/bin because that folder belongs to root, and the reason for that is that the root user has that directory in their $PATH.

If /usr/local/bin was write-accessible to anyone, a malicious user could create a script there named as a common typo, such as cd.., or a common command which is not installed on your system, e.g. lynx or convert. After that, making the expected typo or trying to run the expected command (e.g. double-clicking an HTML/JPEG file in some file managers) while running as root would execute the script, effectively elevating the malicious user's permissions.

If you want to install software for the pi user only, create a folder /home/pi/bin, add it to your $PATH and install your software there. Obviously, this doesn't require root permissions, since there's no risk that root or any other user will accidentally run that software.

And yes, it is absolutely common for software installed from sources to go into /usr/local/bin. You should never install anything in /usr/bin without using your package manager (apt).


You can install Python3.7 with sudo apt-get install python3.7. It's more easier to install it.

  • 1
    That only works on Buster. The OP hasn't upgraded to Buster.
    – Dougie
    Oct 22, 2019 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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