SoFunction
Updated on 2024-11-16

Windows Python installation, use tutorials and Notepad++ tutorials

I. Python Download

1. Go to the official Python website:/

2. Select windows version (Download > Windows)

3. Click to download the latest version of Python 3 (Latest Python 3 Release - Python 3.7.3). You can also choose a lower version, such as Python 3.6.8.

II. Python Installation

Click to run the Python installer

Check "Add pyhon 3.6 to PATH" and click "Install Now" to install by default.

After installation, if you can run python through the following "mode 1", it means that python has been added to the environment variables. If python commands are not recognized in cmd, you need to configure the environment variables manually.

Third, manually configure environment variables

1. Right-click Computer - select Properties - to open the following page

2. Click Advanced System Settings - Environment Variables - to open the following page

Append C:\Users\Fengqiao_x\AppData\Local\Programs\Python\Python36 to the system variable path. Note: The path to append is the path to your python file (blackboard, remember to separate paths with ;).

IV. Python operation

Way 1: Run from the command line (cmd)

1. Enter the command line

2. Type python at the command line to enter the interactive environment. The interactive environment is convenient for beginners to learn Python and experiment with Python.

3. Run the existing Python file from the command line.

In the directory where the Python files are located, type cmd to get to the command line.

On the command line, run the Python program you want to run. For example, type "python "

Way 2: Running in Python's own IDLE

1. Click to enter IDLE

2. Once inside, it's straight to the python interactive environment (knock a line of code, run a line of code)

Run the python file.

Open the python file (File > Open). You can also create a new python file.

Run this file (Run > Run Module). You can also just press the shortcut key F5

V. Use pip to install python modules and packages.

Common commands for pip

Way one:

1. Enter the command line

2. Type in the pip command: pip install package name. Since the download speed of the official python website is too slow, you can download the package from the Tsinghua mirror by adding a parameter (-i)./simple/)。

Way two:

1. Access to Tsinghua Mirror/simple/

2. ctrl+F Find the package you need to install and download it.

3. Open the command line in the download path

4. pip install The name of the file you just downloaded

Method 3: Automated installation with Python code

VI. Use Notepad++ to edit the python file and run it directly

1. Open the python file with notepad++. Or create a new file and save it in .py format.

2. Run the python file directly

Press F5 .

In the popup menu type: cmd /k C:\Users\Fengqiao_x\AppData\Local\Programs\Python\Python36\ "$(FULL_CURRENT_PATH)"& PAUSE & EXIT NOTE: The path must be your python path.

Click Save. Enter your preferred name and shortcut (choose a shortcut that is easy to remember and the shortcut definition cannot be repeated). Then click OK.

Press the shortcut you just typed to run the current python file. From now on, you only need to press the shortcut key to run the python file without the previous steps. The result is as follows.