Score:-1

How to change the version of python from 3.8 to 2.7

us flag

I need to use Python 2.7 in order to use PneumoCaT as it only runs with Python 2.7 not higher versions. I am trying to set my Python version from 3.8 to 2.7 in Ubuntu, but I can't do it.

This is the code I am using.

  1. ls /bin/python*

    I have /bin/python2.7 and /bin/python3.8

  1. python --version comes up with Python 3.8.

  2. sudo update-alternatives --config python

    I can choose from python 2 and 3. I chose python2.

  3. Results of python --version still comes up with Python 3.8.

guiverc avatar
cn flag
You've not provided any OS & release details; but on many on-topic OSes `python` maps to 2.7 by default; but as you've not provided specifics as to what you're running; how can we really help? Guessing can lead to worse problems...
Nmath avatar
ng flag
You should set up a python environment or use a VM. Changing the installed version of python can break your system. Will almost certainly break your system downgrading from 3.8 > 2.7
us flag
`Don't`. Use `python2 /path/to/program.py` instead. Alternatively, use a virtual environment (use your favorite search engine to know how to set it up), which will not mess up with the system's default python version.
Score:4
sa flag

python-is-python2 is a convenience package which ships a symlink to point /usr/bin/python interpreter at the current default python2. It may improve compatibility with obsolete third-party software, while breaking some modern software.

The current default Python 3 version in Ubuntu 20.04 is Python 3.8.10. To install python-is-python2 in Ubuntu 20.04 and later open the terminal and type:

sudo apt update
sudo apt install python-is-python2
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.