banner



How To Install Python In Windows 10 32 Bit

python-on-windows

A step-past-step guide on installing Python and using the Command Prompt for Windows

  • Version: 1.i.0
  • Date: 2022-01-03
  • Author: Alberto Pettarin (contact)
  • License: Creative Commons Attribution 4.0 International (CC Past 4.0)

Overview

Do y'all want to run a Python program under Windows, merely you take no feel using the Command Prompt?

This guide is for you!

I will walk you through the installation of Python and I will explain the basics of the Command Prompt.

After reading this page (and practicing a flake), you should be able to run a Python plan confidently and safely.

What Is Python?

Python is a high-level, general-purpose programming language which allows people to hands create and share programs for a variety of applications.

The Python projection is a costless (libre)/open up source software (FLOSS) initiative, managed by the Python Software Foundation. You lot can download, install, and employ Python for free on several platforms, including Linux, Mac Os Ten, and Windows computers.

Python enables the development of FLOSS programs, which are created for free by millions of volunteers around the globe and shared in source code course. This means that the end user who receives or downloads a Python plan can actually check that the plan does what is supposed to do, and aught more than (dissimilar closed-source programs, which send personal information to third parties, show y'all advertisements, or damage your estimator).

More than details on Python tin can exist establish on the official Python page and on its Wikipedia folio.

In exercise, to use a Python program you need two pieces of software:

  • the Python interpreter, which is the "master" program that reads the source code of a Python programme, and "execute" information technology; and
  • the source lawmaking of the Python program, unremarkably consisting of 1 or more files with .py extension, which performs the specific task you are interested in.

This guide explains how to install the onetime, and it shows how to run the latter in the Command Prompt of Windows, with a complete, existent-life instance.

Installing Python On Windows

The preliminary step consists in installing the Python interpreter (i.e., the "principal program") on your computer.

Installing Python is a one-time operation. If yous already installed Python in the past (for case, to run a different program), you do not need to install information technology again, and y'all tin can skip to the next section.

Step 0: Should I Get Python 2 Or Python iii?

At the time of writing (2017-01-01), there are ii main versions of Python: Python 2 (2.7.13) and Python 3 (iii.half dozen.0).

Discussing the technical differences between these two versions is beyond the scope of this guide. It suffices to say that some Python programs work with both versions of Python, while other Python programs piece of work merely with Python ii but not with Python iii, or vice versa.

You should get the version of Python that the program you are interested in recommends. If the latter does non specify a version, get the latest Python 3 version available. If you later discover that your Python program does non work with the Python version you installed, do non worry: simply uninstall it, and install the other one!

In the remainder of the guide we assume you demand Python iii.

Step 1: Download The Installer

First, open your Web browser and go to https://python.org/:

Python home page

Click on the Download > Latest Python 3.6.0 link.

You volition get a page listing all the new features of Python 3.6.0:

Python 3.6.0 download page

Roll downward until yous run across the list of bachelor downloads:

Python 3.6.0 downloads

If you lot accept a recent Windows computer, very likely information technology is a 64-fleck automobile, so y'all should download the file labeled Windows x86-64 executable installer, and save it on your Download binder or on your Desktop:

Python 3.6.0 downloads

Downloading the file will take from few seconds to a few minutes, depending on the bandwidth of your Internet connection.

(If you have an older PC that you know is a 32-bit computer, download the Windows x86 executable installer instead. You tin tell whether your PC is a 32-chip or a 64-chip machine by reading the Organisation Information in the Windows Control Panel.)

Step 2: Install Python

Double-click on the file you just downloaded to start the installation wizard:

Python 3.6.0 installer

Past default, the Add Python three.6 to PATH selection is disabled, but you should select it, every bit it makes running Python programs much much easier.

Most users should click the Install Now push button, which installs Python with the default settings. (If y'all desire to personalize your installation or you are told to enable some advanced features, click on the Customize installation pick instead.)

The installer might ask you lot for administrative privileges or for confirmations like the post-obit:

Python 3.6.0 installer asking for confirmation

You can safely answer Yep.

A progress bar volition appear:

Python 3.6.0 installer progress bar

until the installation completes with the following message:

Python 3.6.0 installer completed

Starting with Python 3.6.0, information technology is recommended to click on the Disable path length limit option, before closing the installer. If you do so, you lot will become a final confirmation dialog:

Python 3.6.0 installer completed

You lot tin can cease the installation by clicking the Close button.

Congratulations, you have your first Python installation under your belt!

Using The Command Prompt

Most Python programs are command line interface (CLI) utilities, which means that they are not operated via a graphical user interface (GUI), likewise known as "the program window". Instead, they must be executed in the Control Prompt of Windows, also known equally "shell" or "terminal".

Running a CLI program means typing a command cord on the Command Prompt of Windows, following a sure syntax which depends on what the program is supposed to do. You tin can think of this act as reciting the "right spell" to get your job done.

Opening A Command Prompt

To open the Command Prompt, locate the Command Prompt icon in your Start menu (or utilise the search bar):

Command Prompt icon

Click on the icon. A black window appears:

Command Prompt window

The showtime two lines printed in the window show the version of the Command Prompt. The last line, which reads C:\Users\IEUser> in the screenshot above, is the prompt, where y'all tin can actually blazon commands.

The prompt line ever starts with the location of the working directory, that is, the folder where the command prompt is currently interim upon (C:\Users\IEUser in the screenshot above), and ends with the > character.

The prompt ordinarily opens in the home directory of the current user: in fact, we are in C:\Users\IEUser, because the user is called IEUser. If your Windows username is Olga, it is probable you will see C:\Users\Olga instead.

(Different versions of Windows might have different paths for abode directories.)

In the documentation of Python programs you might find a $ character before examples of commands, as follows:

              $ python my_awesome_program.py                          

because on Linux and Mac Os X machines the terminal prompt is usually a $ character.

You lot should not type the $ grapheme, it is but a placeholder for your bodily prompt. For any practical purpose, you tin mentally supplant the $ with your actual prompt, like C:\Users\IEUser> in the example above, as if the documentation was as follows:

              C:\Users\IEUser> python my_awesome_program.py                          

(You will actually type just python my_awesome_program.py and hit the Enter/Return fundamental.)

The Three Safety Rules

By issuing commands on the Command Prompt, you can accidentally delete your ain files or harm Windows, so you lot must be careful.

Do non be agape or discouraged: you practise non stop using knives just considering yous can cut your fingers with them!

By post-obit Three Safety Rules, y'all can operate the prompt safely:

  1. Never consequence a control without understanding what information technology does, and only run programs obtained from developers that you trust.
  2. If annihilation happens in the prompt that y'all do non sympathise, you can only click on the "X" on the correct peak corner to close the Control Prompt window (and hopefully nothing bad volition happen to your files).
  3. E'er re-create your Python program in a split binder, and always make copies of your input files in it, and then that you tin can merely throw away the Python program binder if something goes wrong, and start over.

Changing The Working Directory (cd)

As said above, the command prompt normally opens in the home directory of your user:

Command Prompt window

If y'all want to change the current working directory, yous tin use the cd command. For example, to move to the C:\ directory (the root directory of your C: bulldoze), you blazon cd C:\ and press the Enter/Return key:

Command Prompt window

Notice that the prompt changed to C:\>.

Listing The Contents Of The Working Directory (dir)

If you want a listing of the files or subdirectories contained in the current working directory, issue the dir command, without arguments:

Command Prompt window

The prompt shows a list of directories and files that are independent in the C: drive: in the above screenshot they are BGinfo, PerfLogs, ..., Windows.

At this point, if you want to enter the Users directory, you can simply type cd Users, then on.

If yous want to go up one level, type cd .. (two total stop character). For instance, if you are in C:\Users\ and requite a cd .., you lot volition end up in C:\.

If you lot want to articulate the prompt window, utilise the cls command.

Checking That Python Is Installed Correctly

If yous selected the Add Python to PATH pick, you lot can run the Python interpreter (and any Python programme) from any current working directory.

To bank check this, give the python --version command:

Python non-interactive execution

The Python version will be printed (east.g., Python 3.half dozen.0) and you volition go back to the Windows prompt. You lot merely ran Python in non-interactive mode, pregnant that you provided a precise command ("Python, print the version number yous are"), the Python interpreter performed what you asked for, and then it returned control to the Command Prompt of Windows.

The not-interactive mode is how nigh Python programs work.

If y'all forget to add the --version parameter subsequently the python control, you volition enter the interactive Python beat out instead:

Entering Python interactive shell

Detect how the prompt changed to >>>.

To exit the Python shell, and render to the Command Prompt, just type quit() and hit the Enter/Return key:

Leaving Python interactive shell

Discussing the interactive shell is beyond the scope of this guide, since most programs y'all are interested in are non-interactive.

Running A Python Plan

Splendid, now you have all the tools required to run a Python program on the command line.

As an illustration, I will utilize my simple Python script export-kobo, which reads annotations and highlights from the database file of a Kobo eReader device (KoboReader.sqlite), and prints them on the prompt or exports them to an output file.

Step ane: Download The Source Lawmaking

Starting time, download the source code of the Python plan you want to run.

This commonly implies downloading either a single Python source lawmaking file (with extension .py), or a Zilch file containing several Python source code files and other resource files that y'all need to uncompress somewhere on your disk.

The exact details depend on your Python program, hence exist sure to carefully read its install documentation. Yous can download the prescribed files with your browser, then re-create/uncompress them using the Windows graphical file manager.

In our example, we download the raw file consign-kobo.py from the GitHub repository.

Remember Safety Rule 3 ("copy your Python files into a divide folder")?

We put the downloaded consign-kobo.py file in a new binder C:\export-kobo:

Running a Python program

Note that nosotros also copied the KoboReader.sqlite file (the input of our Python plan) from our Kobo eReader to the same folder.

Stride 2: Open A Command Prompt And cd There

So, open a Command Prompt as explained above, and change the current working directory to the binder where y'all put your Python program source files.

In our example, cd C:\export-kobo:

Running a Python program

A simpler alternative to using the cd command takes advantages of the Windows file explorer. Just navigate the file explorer to the folder where your Python code is:

Opening a prompt from file explorer

and select the File > Open control prompt > Open command prompt bill of fare:

Opening a prompt from file explorer

you lot will go a new Command Prompt window, already located at the correct directory:

Opening a prompt from file explorer

Stride 3: Run The Python Program

At this indicate, we are gear up to run our program.

Blazon python export-kobo.py KoboReader.sqlite --listing and striking Enter/Render:

Running a Python program

The Python interpreter will load our export-kobo.py programme, and run it with arguments KoboReader.sqlite and --list.

Clearly, the semantics of the arguments vary from program to plan, depending on what each program is supposed to do.

In our case, consign-kobo.py volition read the file whose name is passed as the first parameter (KoboReader.sqlite) and it volition list (--list option) the titles of all the eBooks with annotations or highlights in the database.

If nosotros specify different command arguments, for example python export-kobo.py KoboReader.sqlite --csv --output exported.csv, we will become a different beliefs:

Running a Python program

In particular, this 2nd command exported all the information contained in the KoboReader.sqlite file into the newly created file named exported.csv in CSV format:

Running a Python program

You lot must check the documentation of your Python program to know the semantics of its arguments.

Usually, if you run a Python programme without arguments you will become a synopsis of the accepted arguments:

Running without arguments shows the synopsis

If a -h or --aid statement is given, so a more than verbose help message will be printed:

Running with -h shows an help message

Congratulations, at present you should be able to download and run a Python program on your own!

Acknowledgments

  • Louise Schofield nee Stokes for suggesting using the file explorer menu to open the control prompt at a given directory

Source: https://github.com/pettarin/python-on-windows

Posted by: oakleywhaverearld.blogspot.com

0 Response to "How To Install Python In Windows 10 32 Bit"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel