Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python version on Linux
#1
Hello, I'm running Linux Mint Cinnamon 18.3 64-bit and I want to learn Python 3. When I write
python --version
in the Terminal I get
user@user-Lenovo-ideapad-110-17IKB ~ $ python --version
Python 2.7.12
When I write
sudo apt-get install python3.5
in the Terminal I get
user@user-Lenovo-ideapad-110-17IKB ~ $ sudo apt-get install python3.5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.5 is already the newest version (3.5.2-2ubuntu0~16.04.9).
The following packages were automatically installed and are no longer required:
  codeblocks-common libcodeblocks0 libwxbase3.0-0v5 libwxgtk3.0-0v5
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.
How do I know which version I'm running?
Reply
#2
Linux mint18 has bot 2.7 and 3.5 versions.
python2 is the system version (i.e. the one linux rely on for its tools
If you want to use python3 use python3 command, or python3.5 not python.

Note that newest version is 3.8, so if you want to install - install 3.8/
in this case python will point to python2, python3 and python3.5 will point to 3.5 and python3.8 will point to newly installed 3.8
You can use pyenv to manage different installations.
also it's a good idea to work in virtual environments, so that system install is clean. You will need to install different 3-rd party packages and don't want to clutter the system versions.

Look at https://python-forum.io/Thread-Part-1-Li...nvironment
and also - https://python-forum.io/Thread-pyenv-Sim...Management
https://docs.python.org/3/library/venv.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Apr-09-2020, 01:22 PM)buran Wrote: Linux mint18 has bot 2.7 and 3.5 versions.
python2 is the system version (i.e. the one linux rely on for its tools
If you want to use python3 use python3 command, or python3.5 not python.

Note that newest version is 3.8, so if you want to install - install 3.8/
in this case python will point to python2, python3 and python3.5 will point to 3.5 and python3.8 will point to newly installed 3.8
You can use pyenv to manage different installations.
also it's a good idea to work in virtual environments, so that system install is clean. You will need to install different 3-rd party packages and don't want to clutter the system versions.

Look at https://python-forum.io/Thread-Part-1-Li...nvironment
and also - https://python-forum.io/Thread-pyenv-Sim...Management
https://docs.python.org/3/library/venv.html
user@user-Lenovo-ideapad-110-17IKB ~ $ sudo apt-get install python3.8
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.8 is already the newest version (3.8.2-1+xenial1).
The following packages were automatically installed and are no longer required:
  codeblocks-common libcodeblocks0 libwxbase3.0-0v5 libwxgtk3.0-0v5
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.
user@user-Lenovo-ideapad-110-17IKB ~ $ python3 -V
Python 3.5.2
user@user-Lenovo-ideapad-110-17IKB ~ $ 
I installed python 3.8.2 and it's showing that I have 3.5.2?

bump Smile
Reply
#4
try with python3.8 if you want that version. python3 is alias for 3.5
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Apr-10-2020, 06:57 PM)buran Wrote: try with python3.8 if you want that version. python3 is alias for 3.5
user@user-Lenovo-ideapad-110-17IKB ~ $ python3.8 -V
Python 3.8.2
How do I know which version of python is IDLE using? Must I write
#!/usr/bin/python3
or
#!/usr/bin/python3.8
at the beginning of each new program?
Reply
#6
that line is called shebang. It is used only when you want to execute your script from command prompt without using python command in front of it. For that you need to make it executable.
In IDLE it doesn't matter.
you can see https://www.python.org/dev/peps/pep-0394/ for some recommendations what shebang to use.
also https://stackoverflow.com/q/6908143/4046632
For time being you can safely leave your scripts without one. I personally prefer to explicitly invoke the respective python and almost never use shebang
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is possible to run the python command to call python script on linux? cuten222 6 631 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  run part of a script with a different version of Python jdog 2 394 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 679 Oct-04-2023, 10:01 AM
Last Post: snippsat
  How to resolve version conflicts in Python? taeefnajib 0 873 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  Python venv and PIP version issue JanOlvegg 2 1,199 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 852 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Can't update new python version on Pycharm GOKUUUU 6 3,701 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  How to use a variable in linux command in python code? ilknurg 2 1,547 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  Building python (3.9.5) with different libexpat version (2.4.6) raghupcr 0 1,258 Feb-25-2022, 11:29 AM
Last Post: raghupcr
  Python keeps running the old version of the code quest 2 3,645 Jan-20-2022, 07:34 AM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020