Setting Up a Python Environment on Windows

PC

I wanted to create a program to retrieve data from a SwitchBot temperature and humidity sensor, so I set up a Python environment on my Windows PC. This is my personal setup log.

Installing Python

Downloading Python

  1. Go to the official Python website.
  2. From the top menu, select “Downloads” and download the latest version for Windows.

Installing Python

  1. Run the downloaded installer (python-3.x.x.exe).
  2. On the first screen, make sure to check “Add Python to PATH”.
  3. Click “Install Now” to start the installation.
  4. When installation is complete, you’ll see the message “Setup was successful”.

Verifying the Installation

  1. Open Windows PowerShell.
  2. Enter the following command to verify that Python was installed correctly:

Installing Visual Studio Code (VSCode)

Downloading VSCode

  1. Go to the official Visual Studio Code website.
  2. Click “Download for Windows” to download the installer.

Installing VSCode

  1. Run the downloaded installer (VSCodeSetup-x.x.x.exe).
  2. Follow the instructions on the installation screens.
  3. It’s recommended to check the following options during installation:
    • Add to PATH
    • Register Code as an editor for supported file types

Verifying the Installation

  1. Launch VSCode.
  2. Make sure it starts up without any issues.

Setting Up Python Extensions

Installing Extensions

  1. Open VSCode and click the Extensions icon (square icon) on the left sidebar.
  2. Search for “Python” and install the extension provided by Microsoft.

Configuring Extensions

  1. Create or open a Python file (.py).
  2. If you see “Linter not installed” in the bottom-right corner of VSCode, click “Install” and install the recommended linter (e.g., pylint).

Setting the Interpreter

  1. Open the Command Palette (Ctrl + Shift + P).
  2. Type “Python: Select Interpreter” and choose the interpreter you want to use from the list.

Running Python

Creating a Project Folder

  1. Create a new folder anywhere you like.
  2. Open that folder in VSCode.

Creating a Python Script

  1. Inside the folder, create a new Python file (e.g., hello.py).
  2. Enter the following simple Python code:

Running the Python Script

  1. Save the file.
  2. Right-click inside the editor and select “Run Python File in Terminal”.
  3. Check that Hello, World! is displayed in the terminal.

Copied title and URL