I have a fresh installation of Raspbian Lite. This one comes with Python 2.7 and 3.7 and no pip installed. I wanted to install Python 3.9.1 and followed the instructions from here.

To briefly state the steps given there: Install dependencies, extract Python from the downloaded archive, ./configure --enable-optimizations, make and make altinstall.

After completing the installation I realised that Python was installed in /usr/local/bin/python3.9 and pip is installed in usr/local/lib/python3.9/site-packages/pip. While the other Python installations are in /usr/bin/.

  1. Can I (Should I?) somehow have it installed in /usr/bin/?
  2. In the future if I want to install Python and pip in /usr/bin/ what should I change in the above set of commands? I remember seeing in an tutorial article(that I am unable to find now) that they pass additional arguments to ./configure that seemed like specifying the directory to install python in.
  3. Now that it is installed there, I can directly set alias in .bashrc for python3.9 and pip3.9 as python and pip, right?
  • If you choose to install 3.9 you should use the default (correct) directory. There is no need to fiddle with .bashrc - progams installed in /usr/local/bin will run in preference to /usr/bin. You could run specific versions with python3.9 or python3.7
    – Milliways
    Jan 8, 2021 at 22:57

1 Answer 1

  1. No. Do not install it in /usr/bin. /usr/bin is for programs installed by the package manager. If you install packages manually, they go in /usr/local/bin (or ~/.local/bin etc.).
  2. You can use the --prefix option of the configure script to select the folder to install it to, by default the prefix is /usr/local. As mentioned in (1), don't set it to /usr or you'll break things.
  3. Yes.
  • Hi, thanks a lot. After adding these two to .bashrc I updated pip using python3.9 -m pip install --upgrade pip. It showed a small message saying "Defaulting to user installation because normal site-packages is not writable". This is normal, right? After this pip is installed in ~/.local/lib/python3.9/site-packages while setuptools is in /usr/local/lib/.... It seems now all new packages install to ~/.local/lib/... Jan 8, 2021 at 18:16
  • 3. NO! Setting an alias to python is a bad idea, because there are still (old?) programs that expect python2 with that. These programs may fail. The best is, always to call python3.
    – Ingo
    Jan 8, 2021 at 18:38

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.