Skip to main content

Installing Python and xlwings

What is xlwings?

  1. A library that allows you to control Excel using Python
    1. Official site: https://docs.xlwings.org/en/stable/index.html
tip

There are several ways to run Excel with Python. As of 2025-02-10, I consulted ChatGPT and xlwings was recommended. This guide is based on that recommendation.

Info

There are various ways to install Python on Windows, but after some trial and error, I settled on a simple approach.
At first, I tried tools like uv thinking version management might be useful, but since the goal was to replace Excel VBA, additional features turned out to be unnecessary—even a hindrance.

Before Installing Python

  1. Make sure Microsoft Excel is installed
  2. If Python is already installed, check the version:
    1.  python --version
  3. Check the Python version recommended by xlwings:
    1. https://docs.xlwings.org/en/stable/installation.html
  4. If your current version is newer than the recommendation, it should be fine.
    If you need to reinstall, uninstall the old version first.
    1. After uninstalling, check for leftover entries in the PATH or environment variables.
      1. Strange or outdated paths can cause unexpected issues.
tip

Displaying Environment Variables

  1. Press Windows Key + R to open "Run", then enter the following and execute:
    1.  %WINDIR%\System32\SystemPropertiesComputerName.exe
    2. Click the "Advanced" tab > "Environment Variables..."

Installing Python

  1. Download a stable version from the official site (look for one labeled "latest version"):
    1. https://www.python.org/downloads/
    2. Example: python-3.13.2-amd64.exe
  2. Run the downloaded file to install
    1. Enable the option to add Python to PATH if available
      1. This allows you to run it from any location
  3. After installation, check the version in PowerShell:
    1.  python --version
  4. If the version doesn’t appear or something seems wrong, check the executed path:
    1.  gcm python | fl
      1. Here's an example output; line 5 (Path) shows where Python is installed:
        Name            : python.exe
        CommandType : Application
        Definition : C:\Users\<user>\AppData\Local\Programs\Python\Python313\python.exe
        Extension : .exe
        Path : C:\Users\<user>\AppData\Local\Programs\Python\Python313\python.exe
        FileVersionInfo : File: C:\Users\<user>\AppData\Local\Programs\Python\Python313\python.exe
        InternalName: Python Console
        OriginalFilename: python.exe
        FileVersion: 3.13.2
        FileDescription: Python
        Product: Python
        ProductVersion: 3.13.2
        Debug: False
        Patched: False
        PreRelease: False
        PrivateBuild: False
        SpecialBuild: False
        Language: Neutral
    2. If the path differs from the one you just installed, check your environment variables.
      1. If the path is C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\python.exe, this will be prioritized regardless of PATH settings. Delete python.exe and python3.exe from this folder.
        1. tip

          These files only redirect to the Microsoft Store, so it's safe to remove them.

Installing xlwings

  1. Install using pip in PowerShell:
    1.  pip install xlwings
  2. Install the xlwings add-in:
    1.  xlwings addin install
    2. After installation, a new tab for xlwings will appear in Excel
      1. img
  3. That's it!

If You Need Optional Dependencies for xlwings

  1. https://docs.xlwings.org/en/stable/installation.html#optional-dependencies

Updating xlwings

  1.  pip install --upgrade xlwings
  2. After upgrading, reinstall the add-in to sync:
    1.  xlwings addin install