skip to Main Content

On my Debian server if I run python -V it says it’s using Python 2.7.13 even though I have Python 3 installed.

Why isn’t it using Python 3 as default by now? I’m trying to deploy a Django app and it’s expecting Python 3.

4

Answers


  1. You could use pyenv to easily switch between python versions.
    Or just use alias python='/usr/bin/python3.X'.

    Login or Signup to reply.
  2. Why isn’t it using Python 3 as default by now?

    Many distributions have been slow to adopt Python 3 as the default, for a variety of reasons. Luckily, your system default Python should be irrelevant.

    Use a virtual environment, to bundle a Python interpreter (whichever one you want) and related tools like pip along with whatever libraries your application needs.

    Python has supported virtualenvs natively via the venv module since Python 3.3. Alternatively, you can use something like Pipenv or pew for more features.

    There are even tools for installing arbitrary versions of Python like pyenv (which Pipenv uses if available) or pythonz (which pew uses if available), so you’re not limited by whatever version(s) of Python are available via your operating system’s package manager.

    Login or Signup to reply.
  3. Debian come with python3 preinstalled, you can check it through python3 --version or python3 -V. by default the system use python2. To check the default python version : python -V

    To set python3 as default, use:

    sudo update-alternatives --set python /usr/bin/python3.7
    

    python -V will print your python3 version.

    To update update-alternatives, see this answer on U&L

    Login or Signup to reply.
  4. If you really need it you can use:

    alias python='python3'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search