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.
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
You could use pyenv to easily switch between python versions.
Or just use
alias python='/usr/bin/python3.X'
.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 orpew
for more features.There are even tools for installing arbitrary versions of Python like
pyenv
(which Pipenv uses if available) orpythonz
(whichpew
uses if available), so you’re not limited by whatever version(s) of Python are available via your operating system’s package manager.Debian come with
python3
preinstalled, you can check it throughpython3 --version
orpython3 -V
. by default the system usepython2
. To check the default python version :python -V
To set
python3
as default, use:python -V
will print your python3 version.To update
update-alternatives
, see this answer on U&LIf you really need it you can use: