Skip to content

Chapter 0: Environment Setup and Development Tools (Windows, Anaconda)

Updated: 2026-09-08 19:10 · English
Table of contents (10)

Language / 语言: English | 中文版

We use two software packages in this course:

  1. Anaconda: Provides the Python runtime environment and the Conda package manager.
  2. Visual Studio Code (VS Code): A code editor used to write and edit programs.

Version Note (2026-09-08): Current system requirements for Anaconda Distribution on Windows require Windows 11 23H2 or newer on 64-bit x86 architecture. Support for Windows 11 23H2 and earlier versions is scheduled to end on 2026-11-10. Windows 10 users can check the archive documentation and choose a compatible older installer. Review the system requirements and legacy OS installation notes before installing.

Version numbers shown here illustrate output formats; actual numbers may vary. Software menus and button labels may also change over time. Mac users should read the macOS version (Anaconda). If you prefer a lightweight, standard Python setup, read the Windows version (Standard Python).

This chapter covers downloading, installing, and configuring both tools on Windows, followed by writing and running your first Python program. After running the program successfully, we examine how these tools work together.


Part 1: Core Track

0.1 Install Anaconda

0.1.1 Download the Installer

  1. Go to the Anaconda download page to find the Windows graphical installer for Anaconda Distribution.
  2. If the page prompts for registration, click Skip registration to proceed to the download options.
  3. Verify that the installer matches your system architecture. The 64-bit Windows graphical installer filename contains Windows-x86_64.exe.
  4. If you need an earlier release, browse the official archive by filename, release date, and release notes. Record the installer filename after downloading. This helps if you need to look up documentation later.

0.1.2 Installation Steps

After the download finishes, double-click the .exe installer and follow these steps:

  1. Welcome: Click Next.
  2. License Agreement: Read the terms and click I Agree.
  3. Select Installation Type:
    • Choose between Just Me (recommended) and All Users.
    • Select Just Me, then click Next.
  4. Choose Install Location:
    • The default destination is usually C:\Users\username\anaconda3.
    • Use an installation path without spaces or non-ASCII characters, located where your account has write permissions. To change the location, click Browse... and note the selected folder.
    • Confirm that you have sufficient disk space (typically at least 5 GB), then click Next.
  5. Advanced Options:
    • Check Register Anaconda3 as my default Python 3.x.
    • Leave "Add Anaconda3 to my PATH environment variable" unchecked to prevent conflicts with other software.
    • Click Install to begin.
  6. Complete Installation: Installation time depends on your computer hardware. Once the progress bar finishes, click Next. On the final screen, uncheck the tutorial options and click Finish.

0.1.3 Verify the Installation

After installation, verify that Conda and Python run correctly:

Example: Open the Anaconda Prompt from the Windows Start menu to inspect the installed Conda and Python version numbers.

  1. Open the Windows Start menu.
  2. Type Anaconda Prompt in the search box.
  3. Open Anaconda Prompt, which provides a command-line terminal configured for Anaconda.
  4. At the prompt, enter the following command and press Enter:
    bash
    conda --version
    
    If the output displays a version string like conda 24.x.x, Conda is ready.
  5. Enter the next command and press Enter:
    bash
    python --version
    
    If the output displays a version string like Python 3.12.x, Python is installed correctly. You can now close the terminal window.

0.2 Install Visual Studio Code

0.2.1 Download the Installer

  1. Open your browser and visit the VS Code download page.
  2. Under the Windows logo, click Windows (User Installer) to download the 64-bit installer.
  3. The downloaded file is typically named VSCodeUserSetup-x64-1.xx.x.exe.

0.2.2 Installation Steps

Double-click the downloaded setup file and follow the wizard:

  1. License Agreement: Select "I accept the agreement" and click "Next".
  2. Destination Location: Keep the default path and click "Next".
  3. Start Menu Folder: Keep the default and click "Next".
  4. Select Additional Tasks: We recommend selecting these options:
    • Check Create a desktop icon.
    • Check Add "Open with Code" action to Windows Explorer file context menu.
    • Check Add "Open with Code" action to Windows Explorer directory context menu.
    • Check Register Code as an editor for supported file types.
    • Check Add to PATH (requires shell restart) (selected by default). Click "Next".
  5. Ready to Install: Click "Install" and wait for the files to copy.
  6. Finish: Check "Launch Visual Studio Code" and click "Finish".

0.3 Initial VS Code Setup

A fresh VS Code installation uses English by default and needs the Python extension. Complete these three configuration steps:

0.3.1 Install Language Pack (Optional)

If you prefer an interface language other than English (such as Simplified Chinese):

  1. Open VS Code and click the four-square icon in the left activity bar (Extensions, shortcut: Ctrl + Shift + X).
  2. Type Chinese (or your preferred language) in the search box.
  3. Find the official language pack published by Microsoft (such as Chinese (Simplified) Language Pack for Visual Studio Code).
  4. Click Install.
  5. When prompted in the lower-right corner to "Change Language and Restart", click the button to restart VS Code with the new language.

0.3.2 Install the Python Extension

  1. Click the Extensions icon in the left activity bar (or press Ctrl + Shift + X).
  2. In the search box, enter Python.
  3. Locate the official Python extension published by Microsoft (marked with the blue and yellow Python logo).
  4. Click Install and wait for the installation to finish.

0.3.3 Select the Anaconda Python Interpreter

Connect VS Code to the newly installed Anaconda environment:

  1. Press Ctrl + Shift + P (or choose "View" -> "Command Palette..." from the top menu) to open the command palette.
  2. Type Python: Select Interpreter and select the matching command.
  3. VS Code displays the detected Python environments. Select the entry labeled with conda or base, typically pointing to C:\Users\username\anaconda3\python.exe (or your custom install directory).
  4. After selection, the bottom status bar displays the active environment name, such as Python 3.12.x ('base': conda).

0.4 Write and Run Your First Program

Next, create a dedicated project folder, then save and run your first program.

0.4.1 Create a Working Directory

Keep your course programs in a single folder for organized access.

Example: Create a python_code folder, use it to store course files, and open it in VS Code.

  1. Open File Explorer and create a new folder named python_code in a directory where you have write permissions.
  2. In VS Code, select File -> Open Folder... from the top menu.
  3. Select the python_code folder and click Select Folder.
  4. When prompted with the dialog asking "Do you trust the authors of the files in this folder?", click Yes, I trust the authors.

0.4.2 Create a Source File

  1. In the VS Code Explorer sidebar on the left, locate the PYTHON_CODE folder header.
  2. Hover over the folder name and click the New File icon (a file icon with a plus sign).
  3. Type the filename hello.py and press Enter. (Python source files use the .py extension.)
  4. An empty editor tab for hello.py opens.

0.4.3 Write and Execute the Code

In the hello.py editor tab, type this line:

Example: Run one line of code to print Hello, world! to the terminal.

python
print("Hello, world!")

Press Ctrl + S to save the file. (An unsaved file shows a solid dot next to its filename; saving removes the dot.)

Running the Program (Choose Either Method):

  • Method 1 (Recommended): Click the triangular Play button in the upper-right corner of the editor (tooltip: "Run Python File in Dedicated Terminal").
  • Method 2: Right-click anywhere in the code editor and choose "Run Python File in Terminal".

VS Code opens an integrated terminal panel at the bottom and prints the output:

text
Hello, world!

Seeing this text confirms that the Python interpreter executed hello.py successfully. Replace the text inside the quotes with your name, run the file again, and observe the new output.


0.5 Understanding the Tools

0.5.1 The Python Interpreter and Anaconda

The Python interpreter reads and executes Python code. When you ran hello.py, the interpreter executed the print(...) statement and wrote text to the terminal.

Anaconda provides Python together with a collection of standard packages. This chapter uses the Python environment included in Anaconda. Conda manages packages and virtual environments, allowing you to install additional libraries when needed.

0.5.2 VS Code

VS Code is a code editor. It highlights syntax, suggests autocompletions, and hosts an integrated terminal in one window. With the Python extension installed, it detects interpreters and executes .py files.

0.5.3 From Source File to Program Output

  1. Save hello.py in VS Code.
  2. Trigger "Run Python File in Terminal".
  3. The selected Python interpreter executes the file.
  4. The terminal displays the printed results.

Writing code and running code are separate steps. Knowing which file and which interpreter you are running makes it easier to diagnose issues, such as code changes that do not seem to take effect or packages that cannot be found.


Part 2: Supplementary Notes

0.6 Troubleshooting Common Issues (FAQ)

0.6.1 Errors Caused by Non-ASCII Characters in the Install Path

  • Symptom: During installation, Anaconda reports Error: Path contains non-ASCII characters, or the terminal fails to launch after installation.
  • Cause: The Windows user profile folder contains non-ASCII characters (such as C:\Users\张三). Some scientific libraries do not handle non-ASCII paths reliably.
  • Solution: Run the installer again. In the "Choose Install Location" step, click Browse... and choose an ASCII-only path, such as C:\anaconda3 or D:\anaconda3.

0.6.2 PowerShell Script Execution Policy Error

If the terminal reports that activate.ps1 cannot be loaded because running scripts is disabled on this system, the current execution policy blocks the activation script. Open a standard PowerShell window using the same version as the failing terminal and run:

Example: Set the execution policy for the current user so that local environment activation scripts can run.

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

When prompted, type Y and press Enter. Then reopen the VS Code terminal. The -Scope CurrentUser parameter applies only to your account and does not require administrator privileges. If system group policies override this setting, consult the Microsoft execution policy documentation or your lab system administrator.

0.6.3 Missing Run Button or Unselected Interpreter

  • Symptom: The triangular run button does not appear in the top-right corner, or a prompt says Select an Interpreter.
  • Solution:
    1. Confirm that the filename ends in .py. If saved as .txt, VS Code will not activate Python tooling.
    2. Press Ctrl + Shift + P, type Python: Select Interpreter, and press Enter.
    3. In the list that appears, select the Python path containing conda.

0.7 Productivity Settings

0.7.1 Enabling Auto Save

Saving files with Ctrl + S before running them is a good habit. The "Run Python File in Terminal" command in the Python extension also saves the active file before execution, though other launch methods may not. See the official run documentation.

To enable Auto Save in VS Code:

  1. Click File in the top menu bar.
  2. Select Auto Save.
  3. VS Code saves dirty files automatically according to its configuration.

0.7.2 Keyboard Shortcuts

Shortcut Description
Ctrl + S Save the active file
Ctrl + / Toggle single-line comment (adds or removes #)
Ctrl + Shift + P Open the Command Palette
Ctrl + B Show or hide the primary sidebar
Ctrl + Backtick Show or hide the integrated terminal

0.8 Basic Conda Commands

Most course programs run directly from VS Code. If you want to inspect your environment from the command line, open the Anaconda Prompt from the Start menu:

Example: List all packages installed in the active Anaconda environment.

bash
conda list

Common Commands:

  • conda --version: Print the Conda version.
  • conda list: List installed packages and versions.
  • python: Start the interactive Python shell (type exit() to quit).
  • python filename.py: Execute a script file directly.

Self-Check

Record your Windows version, the Anaconda installer filename, the output of python --version, and the interpreter path. Review the official documentation to explain why this installer matches your computer architecture. Then modify the printed text in hello.py and run it again.


Navigation: Course overview (Chinese) | Next: Chapter 1 Basic Data Types and Operations (Chinese)

The English version of Chapter 1 is not yet available.