Is Python installed by default with Linux Mint?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Fran_3
Level 2
Level 2
Posts: 92
Joined: Tue Jul 28, 2020 5:13 pm

Is Python installed by default with Linux Mint?

Post by Fran_3 »

I'm running Linux Mint 20 with all updates.

I recently attempted to run some code and got the message
"Python is not in the Path"
or something like that.

Question 1: Is Python installed automatically with the Linux Mint installation or must I do it after Mint is installed andr unning?

Question 2: So, if Python is not installed by default... which "python" in "Software Manager" do I install?

Question 3: How do I add Python to the Path in Linux Mint?

Thanks for any help.
t42
Level 11
Level 11
Posts: 3686
Joined: Mon Jan 20, 2014 6:48 pm

Re: Is Python installed by default with Linux Mint?

Post by t42 »

Is Python installed automatically with the Linux Mint
Yes, it is. You can check it with such commands:

Code: Select all

python --version
Python 3.8.5
python3 --version
Python 3.8.5
python2 --version
Python 2.7.18
file /usr/bin/python
/usr/bin/python: symbolic link to /usr/bin/python3
file /usr/bin/python3
/usr/bin/python3: symbolic link to python3.8
file /usr/bin/python3.8
/usr/bin/python3.8: ELF 64-bit LSB executable
How to set your $PATH variable in Linux
-=t42=-
Moonstone Man
Level 16
Level 16
Posts: 6078
Joined: Mon Aug 27, 2012 10:17 pm

Re: Is Python installed by default with Linux Mint?

Post by Moonstone Man »

Fran_3 wrote: Wed Apr 14, 2021 8:50 pm Thanks for any help.
t42's answer is fine, but I'll add that you need to be careful installing updated or different versions of python. If you need a different version then install a python virtual environment first, e.g. virtualenv, then install the different version in the virtual python environment. Failure to do this will render your system useless.
User avatar
spamegg
Level 13
Level 13
Posts: 4782
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Is Python installed by default with Linux Mint?

Post by spamegg »

Yep, what Kadaitcha Man said. If you need different Python versions for development don't manually install them system-wide. Use a virtual environment with your IDE (such as PyCharm) . You can also use PyEnv to safely install and use many different Python versions:
https://github.com/pyenv/pyenv/
Currently I have more than 10 versions installed without affecting the system at all.
Fran_3
Level 2
Level 2
Posts: 92
Joined: Tue Jul 28, 2020 5:13 pm

Re: Is Python installed by default with Linux Mint?

Post by Fran_3 »

OK... I have Python just like you guys said... no need to install another version.

FYI entering...
ls /usr/bin/python*
tells me I have python 2.7, 3, and 3.8

So to launch Python from the prompt I enter...
python3.8
right?

thanks for the help guys.
djph
Level 7
Level 7
Posts: 1869
Joined: Thu Jun 27, 2019 5:43 am
Location: ::1

Re: Is Python installed by default with Linux Mint?

Post by djph »

Fran_3 wrote: Thu Apr 15, 2021 7:29 pm OK... I have Python just like you guys said... no need to install another version.

FYI entering...
ls /usr/bin/python*
tells me I have python 2.7, 3, and 3.8

So to launch Python from the prompt I enter...
python3.8
right?
"python" is python2.x and "python3" is python3.x (edit -- er, well on mint 19; 20 might've changed that...)
User avatar
zcot
Level 9
Level 9
Posts: 2781
Joined: Wed Oct 19, 2016 6:08 pm

Re: Is Python installed by default with Linux Mint?

Post by zcot »

For ease, so you don't have to set symlinks on your own, you can install package python-is-python2 or python-is-python3 and it will allow you to run your command as mentioned, -just calling the python command.

I would suspect that you might have some python 2 code, because since python version 3 the motivation is to clarify that version in the code, so a shebang line will specifically state python3, not just python.

Or even if you are looking to do something interactive, either of the above packages will set up an easy situation to be able to just use the python command and it will point to either the python2 or the python3 binary setup. Back in the python v.2 days there was not clarification for version and simply using the command python was acceptable, but that has changed.

If you are writing something, then it seems like python3 is the obvious choice of what you should be using and you would clarify that in a script, or properly initiate an interactive session. So if you are not using any older stuff but strictly writing new stuff then you don't have to do anything, and should just specifically deal with it all as python3 correctly in the first place, either initiate interactive python3 or state that correct shebang line in a script.
t42
Level 11
Level 11
Posts: 3686
Joined: Mon Jan 20, 2014 6:48 pm

Re: Is Python installed by default with Linux Mint?

Post by t42 »

Fran_3 wrote: Thu Apr 15, 2021 7:29 pm So to launch Python from the prompt I enter...
python3.8
right?
In Linux Mint 20.x /usr/bin/python is a symbolic links to /usr/bin/python3
So to start python 3.8.x just enter python at command promt.

You can check that
file /usr/bin/python
output:
/usr/bin/python: symbolic link to /usr/bin/python3

python --version
output:
Python 3.8.5
-=t42=-
Locked

Return to “Beginner Questions”