How to install python latest version

Download and Install Python 3 Latest Version

Here we will be discussing how to get the answer to all questions related to installing Python on Windows/Linux/mac OS. Python was developed by Guido van Rossum in the early 1990’s and its latest version is 3.11.2, we can simply call it Python 3. To understand how to install Python You need to know What Python is and where it is actually installed in your system. Let’s consider a few points:

  • Python is a widely-used general-purpose, high-level programming language.
  • Every Release of Python is open-source. Python releases have also been General Public License (GPL) -compatible.
  • Any version of Python can be downloaded from Python Software Foundation website at python.org.
  • Most the languages, notably Linux provides a package manager through which you can directly install Python on your Operating System
Читайте также:  Bootstrap css text styles

In this Python tutorial on Installation and Setup, you’ll see how to install Python on Windows, mac OS, Linux, iOS, and Android.

Python Latest Version Installation and Setup

How to install Python on Windows?

Since windows don’t come with Python preinstalled, it needs to be installed explicitly. Here we will define step by step tutorial on How to install Python on Windows. Follow the steps below :

Download Python Latest Version from python.org

Step 1: First and foremost step is to open a browser and type https://www.python.org/downloads/windows/

Step 2: Underneath the Python Releases for Windows find the Latest Python 3 Release – Python 3.11.2 (the latest stable release as of now is Python 3.11.2).

Step 3: On this page move to Files and click on Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit.

Here we are providing the installation process of Python 3.11.2 on Windows

  • Run the Python Installer for how to install python on windows downloads folder
  • Make sure to mark Add Python 3.11 to PATH otherwise you will have to do it explicitly. It will start installing python on windows.

  • After installation is complete click on Close. Bingo. Python is installed. Now go to windows and type IDLE.

  • This is Python Interpreter also called Python Shell. I printed Hello geeks, python is working smoothly.
  • The three greater than >>> sign is called Python command prompt, where we write our program and with a single enter key, it will give result so instantly.

How to install Python on Linux?

On every Linux system including the following OS,

  • Ubuntu
  • Linux Mint
  • Debian
  • openSUSE
  • CentOS
  • Fedora
  • and my favorite one, Arch Linux.

You will find Python already installed. You can check it using the following command from the terminal

To check the latest version of python 2.x.x :

To check the latest version of python 3.x.x :

Clearly, it won’t be the latest version of python. There can be multiple methods to install python on a Linux base system and it all depends on your Linux system. For almost every Linux system, the following commands would work definitely.

$ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.11.2

Download and install Python’s Latest Version on Linux

To install the latest version from the source code of Python follow the below steps:

Download Python Latest Version from python.org

  • Underneath the Stable Releases find Download Gzipped source tarball (latest stable release as of now is Python 3.11.2).

Download and install Homebrew Package Manager

  • If you don’t have homebrew installed on your system, follow the steps below Open the Terminal Application of macOS from Application -> Utilities. Bash terminal will open where you can enter commands Enter following command in macOS terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Enter the system password if prompted. This will install the Homebrew package Manager on your OS. After you see a message called “Installation Successful”. You are ready to install python version 3 on your macOS.

Install Python Latest Version on macOS / macOS X

  • To install python simple open Terminal app from Application -> Utilities and enter following command

  • After command processing is complete, Python’s version 3 would be installed on your mac. To verify the installation enter following commands in your Terminal app

  • Bingo. Python is installed on your computer. You can explore more about Python here
  • Offline Python 3.11 interpreter: no Internet is required to run Python programs.
  • Pip package manager and a custom repository for prebuilt wheel packages for enhanced scientific libraries, such as numpy, scipy, matplotlib, scikit-learn.
  • Tensorflow is now also available.
  • Examples available out-of-the-box for quicker learning.
  • Complete Tkinter support for GUI.
  • Full-featured Terminal Emulator, with a readline support (available in pip).
  • To install Pydroid app go to play store link here – Pydroid 3 – IDE for Python 3
  • After installation is complete, run the app and it will show as installing python.
  • Wait for a minute and it will show the ide. Here you can enter the Python code.
  • Click on the yellow button to run the code.

Python is installed successfully. You can check more features of this app here.

  • GeeksforGeeks IDE – ide.geeksforgeeks.org
  • Python Fiddle: pythonfiddle.com
  • Python Anywhere: www.pythonanywhere.com
  • Online gdp compiler – onlinegdb.com
  • kaggle – kaggle.com
  • JuPyter/IPython Notebook – jupyter.org
  • Google Colab – colab.research.google.com

Источник

Upgrade Python to latest version (3.10) on Ubuntu Linux

Linux systems come with Python install by default, but, they are usually not the latest. Python also cannot be updated by a typical apt upgrade command as well.

To check the version of Python installed on your system run

python keyword is used for Python 2.x versions which has been deprecated

  1. Update Python to the latest version
  2. Fix pip & other Python related issues
  3. While doing the above two, ensure your Ubuntu which is heavily dependent on Python does not break

Updating Python to the latest version

Ubuntu’s default repositories do not contain the latest version of Python, but an open source repository named deadsnakes does.

Python3.10 is not officially available on Ubuntu 20.04, ensure you backup your system before upgrading.

Step 1: Check if Python3.10 is available for install

sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update 

Check if Python 3.10 is available by running

This will produce the below result, if you see python3.10 it means you can install it

Step 2: Install Python 3.10

Now you can install Python 3.10 by running

sudo apt install python3.10 

Now though Python 3.10 is installed, if you check the version of your python by running python3 —version you will still see an older version. This is because you have two versions of Python installed and you need to choose Python 3.10 as the default.

Step 3: Set Python 3.10 as default

Steps beyond here are tested on Ubuntu 20.04 in VM & WSL2, but are experimental , proceed at your own risk.

Changing the default alternatives for Python will break your Gnome terminal. To avoid this, you need to edit the gnome-terminal configuration file.

Open the terminal and run:

sudo nano /usr/bin/gnome-terminal 

In first line, change #!/usr/bin/python3 to #!/usr/bin/python3.8 . Press Ctrl +X followed by enter to save and exit.

Then save and close the file.

Next, update the default Python by adding both versions to an alternatives by running the below

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 Now run
sudo update-alternatives --config python3 

Choose the selection corresponding to Python3.10 (if not selected by default).

Now run python3 —version again and you should see the latest Python as the output.

Fix pip and disutils errors

Installing the new version of Python will break pip as the distutils for Python3.10 is not installed yet.

Fix Python3-apt

Running pip in terminal will not work, as the current pip is not compatible with Python3.10 and python3-apt will be broken, that will generate an error like

Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' 

To fix this first remove the current version of python3-apt by running

sudo apt remove --purge python3-apt 

DO NOT RUN sudo apt autoremove as it will remove several packages that are required. This may break your system if you’re using GUI, if you’re on WSL2 you can proceed.

Finally, reinstall python3-apt by running

sudo apt install python3-apt 

Install pip & distutils

Running pip will still throw an error pip: command not found . We need to install the latest version of pip compatible with Python 3.10.

Also, if try to manually install the latest version of pip, it will throw an error like

ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.10/distutils/__init__.py) 

Or you might also see an error stating No module named ‘distutils.util’ . This is because the distutils module is not installed yet, to install run the below command

sudo apt install python3.10-distutils 

Now you can install pip by running

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python3.10 get-pip.py 

If you get an error like bash: curl: command not found then you need to install curl first by running sudo apt install curl

Now you can run pip and you should see the output of pip —version

Fix pip-env errors when using venv

When you try to create a new virtual environment using python -m venv env , you may into the following error.

Error: Command -Imensurepip--upgrade--default-pipYou can fix this by reinstalling venv by running
sudo apt install python3.10-venv 

All should be done now. It is complicated, but this is how you update Python to latest version.

Extra

If you have oh-my-zsh installed, you can avoid typing out python3 by running

Now you can run your files with py or python .

Источник

User

On many systems Python comes pre-installed, you can try running the python command to start the Python interpreter to check and see if it is already installed. On windows you can try the py command which is a launcher which is more likely to work. If it is installed you will see a response which will include the version number, for example:

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

If you don’t see this, you will need to install Python on your system.

If the version number is Python 2.x.y (where x and y are any number) you are using Python 2 which is no longer supported and is not a good choice for development. You can try running python3 to see if there is also a Python 3.x.y version installed, if not you’ll want to install the latest version of Python.

If you do not have Python installed or need a newer version you can go to:

which will provide a button to download an installer for your particular system. The Python documentation also has a detailed guide on how to install and setup Python here:

Below are some system specific notes to keep in mind.

Windows

On Windows the most stable build is available from the official download page

You should download and run the installer from that page to get the latest version of Python for your system. You can refer to the Python documentation for more details on the installation process and getting started:

Mac

For macOS 10.9 (Jaguar) up until 12.3 (Catalina) the operating system includes Python 2, which is no longer supported and is not a good choice for development. You should go to do the downloads page: https://www.python.org/downloads/ and download the installer.

For newer versions of macOS, Python is no longer included by default and you will have to download and install it. You can refer to the Python documentation for more details on the installation process and getting started:

Linux

On most Linux distributions Python comes pre-installed and/or available via the distribution’s package managers. Below are some common examples, but refer to your specific distribution’s documentation and package list to get the most up to date instructions.

If you’d like to download and build Python from source (or your distribution’s package manager does not include a version of Python you need) you can download a source tarball from the general download page: https://www.python.org/downloads/

Red Hat, CentOS, or Fedora

dnf install python3 python3-devel

Debian or Ubuntu

apt-get install python3 python3-dev

Источник

Оцените статью