Installing Python and xlwings
What is xlwings?
- A library that allows you to control Excel using Python
- 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
- Make sure Microsoft Excel is installed
- If Python is already installed, check the version:
-
python --version
-
- Check the Python version recommended by xlwings:
- If your current version is newer than the recommendation, it should be fine.
If you need to reinstall, uninstall the old version first.- After uninstalling, check for leftover entries in the PATH or environment variables.
- Strange or outdated paths can cause unexpected issues.
- After uninstalling, check for leftover entries in the PATH or environment variables.
tip
Displaying Environment Variables
- Press Windows Key + R to open "Run", then enter the following and execute:
-
%WINDIR%\System32\SystemPropertiesComputerName.exe
- Click the "Advanced" tab > "Environment Variables..."
-
Installing Python
- Download a stable version from the official site (look for one labeled "latest version"):
- https://www.python.org/downloads/
- Example:
python-3.13.2-amd64.exe
- Run the downloaded file to install
- Enable the option to add Python to PATH if available
- This allows you to run it from any location
- Enable the option to add Python to PATH if available
- After installation, check the version in PowerShell:
-
python --version
-
- If the version doesn’t appear or something seems wrong, check the executed path:
-
gcm python | fl
- 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
- Here's an example output; line 5 (
- If the path differs from the one you just installed, check your environment variables.
- If the path is
C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\python.exe
, this will be prioritized regardless of PATH settings. Deletepython.exe
andpython3.exe
from this folder.-
tip
These files only redirect to the Microsoft Store, so it's safe to remove them.
-
- If the path is
-
Installing xlwings
- Install using pip in PowerShell:
-
pip install xlwings
-
- Install the xlwings add-in:
-
xlwings addin install
- After installation, a new tab for xlwings will appear in Excel
-
- That's it!
If You Need Optional Dependencies for xlwings
Updating xlwings
-
pip install --upgrade xlwings
- After upgrading, reinstall the add-in to sync:
-
xlwings addin install
-