How to install python on windows

How to install python on windows

How to install Python in Windows?

Python is a widely used high-level programming language. To write and execute code in python, we first need to install Python on our system.

Installing Python on Windows takes a series of few easy steps.

Step 1 − Select Version of Python to Install

Python has various versions available with differences between the syntax and working of different versions of the language. We need to choose the version which we want to use or need. There are different versions of Python 2 and Python 3 available.

Step 2 − Download Python Executable Installer

On the web browser, in the official site of python (www.python.org), move to the Download for Windows section.

All the available versions of Python will be listed. Select the version required by you and click on Download. Let suppose, we chose the Python 3.9.1 version.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

On clicking download, various available executable installers shall be visible with different operating system specifications. Choose the installer which suits your system operating system and download the instlaller. Let suppose, we select the Windows installer(64 bits).

The download size is less than 30MB.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Step 3 − Run Executable Installer

We downloaded the Python 3.9.1 Windows 64 bit installer.

Run the installer. Make sure to select both the checkboxes at the bottom and then click Install New.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

On clicking the Install Now, The installation process starts.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

The installation process will take few minutes to complete and once the installation is successful, the following screen is displayed.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Step 4 − Verify Python is installed on Windows

To ensure if Python is succesfully installed on your system. Follow the given steps −

Open the command prompt.

Type ‘python’ and press enter.

The version of the python which you have installed will be displayed if the python is successfully installed on your windows.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Step 5 − Verify Pip was installed

Pip is a powerful package management system for Python software packages. Thus, make sure that you have it installed.

To verify if pip was installed, follow the given steps −

Open the command prompt.

Enter pip –V to check if pip was installed.

The following output appears if pip is installed successfully.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

We have successfully installed python and pip on our Windows system.

How to install Python on Windows?

Before we start with how to install Python3 on Windows, let’s first go through the basic introduction to Python. Python is a widely-used general-purpose, high-level programming language. Python is a programming language that lets you work quickly and integrate systems more efficiently. There are two major Python versions- Python 2 and Python 3. Both are quite different.

Getting started with Python

Python is a lot easier to code and learn. Python programs can be written on any plain text editor like notepad, notepad++, or anything of that sort. One can also use an online IDE for writing Python codes or can even install one on their system to make it more feasible to write these codes because IDEs provide a lot of features like intuitive code editor, debugger, compiler, etc.
To begin with, writing Python Codes and performing various intriguing and useful operations, one must have Python installed on their System. This can be done by following the step by step instructions provided below:

What if Python already exists? Let’s check

To check if your device is pre-installed with Python or not, just go to the Command line(search for cmd in the Run dialog( + R).
Now run the following command:

If Python is already installed, it will generate a message with the Python version available.
How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Download and Install Python:

Before starting with the installation process, you need to download it. For that all versions of Python for Windows are available on python.org.
How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Download the required version and follow the further instructions for the installation process.

Beginning the installation.

To verify the installation enter the following commands in your Terminal.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Let’s consider a simple Hello World Program.

How to Install Python on Windows

Python is one of the most popular programming languages worldwide. Today we will show you how to install Python 2 and Python 3 on Windows operating system.

List of content you will read in this article:

Python doesn’t come pre-installed in Windows. However, it’s not that difficult to install Python on Windows systems and start creating Python programs. Through this article, we will guide you with all the essential information along with the steps that you need to install and run Python in Windows. But before that, let’s take a quick look at Python itself.

Python is a popular high-level programming language that is used extensively in software development as well as web development. It has always been a favorite of hobbyists and qualified developers alike, owing to a design concept that stresses readability. Python is also one of the easiest programming languages to learn and understand, which accounts for its ever-growing popularity.

What Version of Python Would Users Require?

Regrettably, a major upgrade to Python many years ago resulted in a large break among Python releases. This may be a little perplexing for beginners, but don’t worry, we’ll demonstrate how to set up all the major Python versions on Windows.

When you visit Python’s official website and navigate to the Python for Windows downloads tab, you’ll notice a large number of Python versions that are available for download. The registry always asks whether you want to upgrade to the latest version of Python 2 or Python 3.

We recommend running both the version, Python 2 and Python 3 at the same time if you want to get the most out of Python. This helps you to use the latest Python version while still operating older Python scripts and testing the functionality of projects that have been developed using a newer version of Python.

If you’re certain that you only need one version of Python, you may install just Python 2 or Python 3 as per your requirements. However, we’re going the extra mile to show you the installation of each one of these. We suggest you follow the steps closely to be able to install Python on your Windows system successfully. First, install the «x86-64» installer of a particular Python version, which is highlighted in the image as shown below:

Python 2 Installation Instructions

Python 2 is easy to update, and unlike previous versions, the installer will also set the path variable for you (which we’ll discuss later).

Now, you won’t have to make any more choices. To complete the installation, simply follow the wizard’s instructions. When the installation is complete, open Command Prompt and type the following command to validate the installation:

You should stop yourself right here if all you need is Python 2.7 to work on your project. It is installed successfully on your Windows system and the path variable has been configured, so you’re ready to use Python.

Python 3 Installation Instructions

Python 3 must be installed if you wish to work with the most recent version of Python. It’ll fit well with Python 2.7, so go ahead and install it on your system.

We suggest that you choose that alternative. If you are certain that you do not wish to disable the path length restriction, simply press «Close» to complete the installation.

Change Default Settings to Provide Command-Line Access to All Python Versions

The explanation for this is simple; the vector merely points to a folder, and any executable in that directory becomes a command-line command (whether automatically changed by an installer or manually tweaked). If two files are specified with a “python.exe” file in each, the folder that is the highest in the list of variables will be used. The machine path takes precedence over the user path when both process and the operator have parameters configured.

This is precisely what is happening throughout this scenario: the Python 2 installer changed a system-wide variable, while the Python 3 installer introduced a user-level variable, as we can see from the Windows environment variables.

Select the “View advanced system settings” option from the Start menu after typing “advanced system settings” into the search box. On the «Advanced» tab of the «System Properties» window that appears, press the «Environment Variables» button.

In the “User variables” column, Python 3 is listed, while Python 2 is listed in the “System variables” section.

There are a few options for dealing with this. The easiest solution is to simply delete the entry for the Python version you want to use the least. Although this is straightforward, it isn’t particularly enjoyable. Instead, we should make a different modification that allows us to use Python 2 as “python” and Python 3 as “python3”.

To do so, open File Manager and navigate to the Python 3 installation folder (C:\Users\[username]\AppData\Local\Programs\Python\Python36 by default). Make a duplicate of the “python.exe” file, and rename that duplicate to “python3.exe”.

It’s a bang! When you want to use Python 2.7, you can always use the “python” command at the cmd, and when you want to use Python 3, use the “python3” command.

Conclusion

Python is a popular high-level programming language used for software and web development. We have seen how to install Python 2 and Python 3 conveniently. We can also run both versions of Python simultaneously to convert our Python 2 files into Python 3 and vice-versa. Leave your feedback for suggestions or queries in the comments below. Also, if you wish to install Python on Ubuntu instead, please check out this detailed tutorial.

Get started using Python on Windows for beginners

The following is a step-by-step guide for beginners interested in learning Python using Windows.

Set up your development environment

For beginners who are new to Python, we recommend you install Python from the Microsoft Store. Installing via the Microsoft Store uses the basic Python3 interpreter, but handles set up of your PATH settings for the current user (avoiding the need for admin access), in addition to providing automatic updates. This is especially helpful if you are in an educational environment or a part of an organization that restricts permissions or administrative access on your machine.

If you are using Python on Windows for web development, we recommend a different set up for your development environment. Rather than installing directly on Windows, we recommend installing and using Python via the Windows Subsystem for Linux. For help, see: Get started using Python for web development on Windows. If you’re interested in automating common tasks on your operating system, see our guide: Get started using Python on Windows for scripting and automation. For some advanced scenarios (like needing to access/modify Python’s installed files, make copies of binaries, or use Python DLLs directly), you may want to consider downloading a specific Python release directly from python.org or consider installing an alternative, such as Anaconda, Jython, PyPy, WinPython, IronPython, etc. We only recommend this if you are a more advanced Python programmer with a specific reason for choosing an alternative implementation.

Install Python

To install Python using the Microsoft Store:

Go to your Start menu (lower left Windows icon), type «Microsoft Store», select the link to open the store.

Once the store is open, select Search from the upper-right menu and enter «Python». Select which version of Python you would like to use from the results under Apps. We recommend using the most recent unless you have a reason not to (such as aligning with the version used on a pre-existing project that you plan to work on). Once you’ve determined which version you would like to install, select Get.

Install Visual Studio Code

By using VS Code as your text editor / integrated development environment (IDE), you can take advantage of IntelliSense (a code completion aid), Linting (helps avoid making errors in your code), Debug support (helps you find errors in your code after you run it), Code snippets (templates for small reusable code blocks), and Unit testing (testing your code’s interface with different types of input).

VS Code also contains a built-in terminal that enables you to open a Python command line with Windows Command prompt, PowerShell, or whatever you prefer, establishing a seamless workflow between your code editor and command line.

To install VS Code, download VS Code for Windows: https://code.visualstudio.com.

Once VS Code has been installed, you must also install the Python extension. To install the Python extension, you can select the VS Code Marketplace link or open VS Code and search for Python in the extensions menu (Ctrl+Shift+X).

Python is an interpreted language, and in order to run Python code, you must tell VS Code which interpreter to use. We recommend using the most recent version of Python unless you have a specific reason for choosing something different. Once you’ve installed the Python extension, select a Python 3 interpreter by opening the Command Palette (Ctrl+Shift+P), start typing the command Python: Select Interpreter to search, then select the command. You can also use the Select Python Environment option on the bottom Status Bar if available (it may already show a selected interpreter). The command presents a list of available interpreters that VS Code can find automatically, including virtual environments. If you don’t see the desired interpreter, see Configuring Python environments.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

To open the terminal in VS Code, select View > Terminal, or alternatively use the shortcut Ctrl+` (using the backtick character). The default terminal is PowerShell.

Inside your VS Code terminal, open Python by simply entering the command: python

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Install Git (optional)

If you plan to collaborate with others on your Python code, or host your project on an open-source site (like GitHub), VS Code supports version control with Git. The Source Control tab in VS Code tracks all of your changes and has common Git commands (add, commit, push, pull) built right into the UI. You first need to install Git to power the Source Control panel.

Download and install Git for Windows from the git-scm website.

An Install Wizard is included that will ask you a series of questions about settings for your Git installation. We recommend using all of the default settings, unless you have a specific reason for changing something.

If you’ve never worked with Git before, GitHub Guides can help you get started.

Hello World tutorial for some Python basics

Python, according to its creator Guido van Rossum, is a “high-level programming language, and its core design philosophy is all about code readability and a syntax which allows programmers to express concepts in a few lines of code.”

Python is an interpreted language. In contrast to compiled languages, in which the code you write needs to be translated into machine code in order to be run by your computer’s processor, Python code is passed straight to an interpreter and run directly. You just type in your code and run it. Let’s try it!

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Hope you had fun using some of Python’s built-in string modification methods. Now try creating a Python program file and running it with VS Code.

Hello World tutorial for using Python with VS Code

The VS Code team has put together a great Getting Started with Python tutorial walking through how to create a Hello World program with Python, run the program file, configure and run the debugger, and install packages like matplotlib and numpy to create a graphical plot inside a virtual environment.

Open PowerShell and create an empty folder called «hello», navigate into this folder, and open it in VS Code:

Continue the tutorial in the VS Code docs: Create a Python Hello World source code file.

Create a simple game with Pygame

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

All being well, the game will open a window. Close the window when you are done playing.

Here’s how to start writing your own game.

Open PowerShell (or Windows Command Prompt) and create an empty folder called «bounce». Navigate to this folder and create a file named «bounce.py». Open the folder in VS Code:

Using VS Code, enter the following Python code (or copy and paste it):

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Try adjusting some of the numbers to see what effect they have on your bouncing ball.

Read more about writing games with pygame at pygame.org.

Resources for continued learning

We recommend the following resources to support you in continuing to learn about Python development on Windows.

Online courses for learning Python

Introduction to Python on Microsoft Learn: Try the interactive Microsoft Learn platform and earn experience points for completing this module covering the basics on how to write basic Python code, declare variables, and work with console input and output. The interactive sandbox environment makes this a great place to start for folks who don’t have their Python development environment set up yet.

Python on Pluralsight: 8 Courses, 29 Hours: The Python learning path on Pluralsight offers online courses covering a variety of topics related to Python, including a tool to measure your skill and find your gaps.

LearnPython.org Tutorials: Get started on learning Python without needing to install or set anything up with these free interactive Python tutorials from the folks at DataCamp.

The Python.org Tutorials: Introduces the reader informally to the basic concepts and features of the Python language and system.

Learning Python on Lynda.com: A basic introduction to Python.

Working with Python in VS Code

Editing Python in VS Code: Learn more about how to take advantage of VS Code’s autocomplete and IntelliSense support for Python, including how to customize their behavior. or just turn them off.

Linting Python: Linting is the process of running a program that will analyse code for potential errors. Learn about the different forms of linting support VS Code provides for Python and how to set it up.

Debugging Python: Debugging is the process of identifying and removing errors from a computer program. This article covers how to initialize and configure debugging for Python with VS Code, how to set and validate breakpoints, attach a local script, perform debugging for different app types or on a remote computer, and some basic troubleshooting.

Unit testing Python: Covers some background explaining what unit testing means, an example walkthrough, enabling a test framework, creating and running your tests, debugging tests, and test configuration settings.

How To Install Python 3 on Windows 10

Home » DevOps and Development » How To Install Python 3 on Windows 10

Python is a widely used high-level programming language first launched in 1991. Since then, Python has been gaining popularity and is considered as one of the most popular and flexible server-side programming languages.

Unlike most Linux distributions, Windows does not come with the Python programming language by default. However, you can install Python on your Windows server or local machine in just a few easy steps.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Python 3 Installation on Windows

Step 1: Select Version of Python to Install

The version you need depends on what you want to do in Python. For example, if you are working on a project coded in Python version 2.6, you probably need that version. If you are starting a project from scratch, you have the freedom to choose.

If you are learning to code in Python, we recommend you download both the latest version of Python 2 and 3. Working with Python 2 enables you to work on older projects or test new projects for backward compatibility.

Note: If you are installing Python on a remote Windows server, log in via Remote Desktop Protocol (RDP). Once you log in, the installation procedure is the same as for a local Windows machine.

Step 2: Download Python Executable Installer

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Note: If your Windows installation is a 32-bit system, you need the Windows x86 executable installer. If your Windows is a 64-bit version, you need to download the Windows x86-64 executable installer. There is nothing to worry about if you install the “wrong” version. You can uninstall one version of Python and install another.

Step 3: Run Executable Installer

1. Run the Python Installer once downloaded. (In this example, we have downloaded Python 3.7.3.)

2. Make sure you select the Install launcher for all users and Add Python 3.7 to PATH checkboxes. The latter places the interpreter in the execution path. For older versions of Python that do not support the Add Python to Path checkbox, see Step 6.

3. Select Install Now – the recommended installation options.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

For all recent versions of Python, the recommended installation options include Pip and IDLE. Older versions might not include such additional features.

4. The next dialog will prompt you to select whether to Disable path length limit. Choosing this option will allow Python to bypass the 260-character MAX_PATH limit. Effectively, it will enable Python to use long path names.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

The Disable path length limit option will not affect any other system settings. Turning it on will resolve potential name length issues that may arise with Python projects developed in Linux.

Step 4: Verify Python Was Installed On Windows

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Note: You can also check whether the installation was successful by typing python –V in Command Prompt. The output should display your installed version of Python. In our case, it is “Python 3.7.3.”

Step 5: Verify Pip Was Installed

If you opted to install an older version of Python, it is possible that it did not come with Pip preinstalled. Pip is a powerful package management system for Python software packages. Thus, make sure that you have it installed.

We recommend using Pip for most Python packages, especially when working in virtual environments.

To verify whether Pip was installed:

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

Pip has not been installed yet if you get the following output:

If your version of Python is missing Pip, see our article How to Install Pip to Manage Python Packages on Windows.

Step 6: Add Python Path to Environment Variables (Optional)

We recommend you go through this step if your version of the Python installer does not include the Add Python to PATH checkbox or if you have not selected that option.

Setting up the Python path to system variables alleviates the need for using full paths. It instructs Windows to look through all the PATH folders for “python” and find the install folder that contains the python.exe file.

1. Open the Start menu and start the Run app.

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

2. Type sysdm.cpl and click OK. This opens the System Properties window.

3. Navigate to the Advanced tab and select Environment Variables.

4. Under System Variables, find and select the Path variable.

5. Click Edit.

6. Select the Variable value field. Add the path to the python.exe file preceded with a semicolon (;). For example, in the image below, we have added «;C:\Python34.«

How to install python on windows. Смотреть фото How to install python on windows. Смотреть картинку How to install python on windows. Картинка про How to install python on windows. Фото How to install python on windows

7. Click OK and close all windows.

By setting this up, you can execute Python scripts like this: Python script.py

Instead of this: C:/Python34/Python script.py

As you can see, it is cleaner and more manageable.

Step 7: Install virtualnv (Optional)

Why use virtualnv?

Python software packages are installed system-wide by default. Consequently, whenever a single project-specific package is changed, it changes for all your Python projects. You would want to avoid this, and having separate virtual environments for each project is the easiest solution.

To install virtualnv:

1. Open the Start menu and type «cmd

2. Select the Command Prompt application.

3. Type the following pip command in the console:

Upon completion, virtualnv is installed on your system.

In this tutorial, we detailed how to install Python 3.7.3 on Windows. If you are installing a different version of Python, you can expect a similar process.

To upgrade Python to a newer version, check our article how to upgrade Python to 3.9.

Remember, choose your version carefully, make sure that you have Pip installed, and use virtual environments when developing multiple projects on a single system.

Want to try out another new generation, server-side scripting languages? Check out How to Install Ruby on Windows 10.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *