How do I downgrade my version of python from 3.7.5 to 3.6.5 on ubuntu

2124
January 01, 2020, at 12:20 PM

So currently, I have ubuntu 19. And it comes by default with python 3.7.5. I need to downgrade to 3.6.5.

Answer 1

You can also use virtualenv to use different Python environments.

If you type python and tab twice or so, you might see a number of Python versions available. I say this because when I type

python3.6 -V

I have

Python 3.6.9

available. My alias for python is 3.7.5

When you type python you are probably referring to an alias defined in .bashrc

Answer 2

The following talks about upgrade from 3.6.7 to 3.7.0 but you can use the same process for downgrade. You should not change the system python unless you really know what you're doing

First Install Pyenv

Installlation Instructions are here

Look at Pyenv Options
$ pyenv 
pyenv 1.2.14
Usage: pyenv <command> [<args>]
Some useful pyenv commands are:
   commands    List all available pyenv commands
   activate    Activate virtual environment
   commands    List all available pyenv commands
   deactivate   Deactivate virtual environment
   doctor      Verify pyenv installation and deevlopment tools to build pythons.
   exec        Run an executable with the selected Python version
   global      Set or show the global Python version
   help        Display help for a command
   hooks       List hook scripts for a given pyenv command
   init        Configure the shell environment for pyenv
   install     Install a Python version using python-build
   local       Set or show the local application-specific Python version
   prefix      Display prefix for a Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   root        Display the root directory where versions and shims are kept
   shell       Set or show the shell-specific Python version
   shims       List existing pyenv shims
   uninstall   Uninstall a specific Python version
   --version   Display the version of pyenv
   version     Show the current Python version and its origin
   version-file   Detect the file that sets the current pyenv version
   version-name   Show the current Python version
   version-origin   Explain how the current Python version is set
   versions    List all Python versions available to pyenv
   virtualenv   Create a Python virtualenv using the pyenv-virtualenv plugin
   virtualenv-delete   Uninstall a specific Python virtualenv
   virtualenv-init   Configure the shell environment for pyenv-virtualenv
   virtualenv-prefix   Display real_prefix for a Python virtualenv version
   virtualenvs   List all Python virtualenvs found in `$PYENV_ROOT/versions/*'.
   whence      List all Python versions that contain the given executable
   which       Display the full path to an executable
See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme
Look at Python Versions
$ pyenv versions
  system
 * 3.6.7 (set by /home/taarimalta/.pyenv/version)
Install a new Python
$ pyenv install 3.7.0
Installing Python-3.7.0...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installed Python-3.7.0 to /home/taarimalta/.pyenv/versions/3.7.0

If you run into an issue with _ctypes install libffi-dev library

Now look at the versions

$ pyenv versions
  system
* 3.6.7 (set by /home/taarimalta/.pyenv/version)
  3.7.0
Select 3.7.0 for local environment
$ pyenv local 3.7.0

See that the version changed

$ pyenv versions
  system
  3.6.7
 * 3.7.0 (set by /home/taarimalta/.python-version)
$ python
Python 3.7.0 (default, Jan  1 2020, 10:52:57) 
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
READ ALSO
Failing when inserting generated column of date or time type from a datetime/timstamp source

Failing when inserting generated column of date or time type from a datetime/timstamp source

A generated column is a column containing the result of an expression or function based on another fieldI want a simple date and time field derived from a datetime field, but to insert records I must adopt a workaround

99
What is the best way to load the bootstrap card with contents dynamically?

What is the best way to load the bootstrap card with contents dynamically?

I am a beginner in web developmentI need to create a page with bootstrap card dynamically by fetching values from database

97
Why a named function declaration isn&#39;t hoisted if you put it inside the return statement?

Why a named function declaration isn't hoisted if you put it inside the return statement?

is putting the function declaration beside the return statement causing the function not to hoist? or putting it inside the return statement turns it into a function expression that's why it isn't hoisted?

68