I didn't know that Python 3.6 had already been installed by some package before I installed Python 3.9.6 onto my system.
I followed the steps found at https://phoenixnap.com/kb/how-to-install-python-3-ubuntu#ftoc-heading-7
-
sudo apt update
-
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
-
cd /tmp
-
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
-
tar -xf Python-3.9.6.tgz
-
cd python-3.9.6
-
./configure --enable-optimizations
(Overwrite Default Python Installation)
"To install Python 3.9.6 over the top of your existing Python, enter the following":
sudo make install
After these steps, I found out that I have 3 versions of python:
$ python -V
Python 3.6.9
$ python2 -V
Python 2.7.17
$ python3 -V
Python 3.9.6
I then ran:
sudo apt update
The terminal returned:
File "/usr/local/bin/apt", line 6
print "apt"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("apt")?
I could run other commands like sudo apt-get
... etc.
Could someone please tell me what went wrong?
Edit: Thank you Joshua Johns, steeldriver & vanadium for your help. I did the followings to verify:
$ ls -l /usr/bin/python
/usr/bin/python -> /etc/alternatives/python
$ ls -l /etc/alternatives/python
/etc/alternatives/python -> /usr/bin/python3
$ ls -l /usr/bin/python3
/usr/bin/python3 -> python3.6
$ ls -l /usr/bin/python2
/usr/bin/python2 -> python2.7
$ which python3 /usr/local/bin/python3
$ ls -l /usr/local/bin/python3
/usr/local/bin/python3 -> python3.9