Yes, but each Python version needs its own PyXLL install, and each Excel process can only load one of them.
-
One build per Python version. The PyXLL add-in (
pyxll.xll) is built for a specific Python version. A build for Python 3.12 will not work with Python 3.14, and vice versa. -
The config file can't change the Python version. The
executablesetting inpyxll.cfgswitches between virtual environments or Python distributions of the same version. Pointing it at a different version will not work. - One PyXLL add-in per Excel process. You can keep several PyXLL installs side by side and switch between them. You can also run two separate Excel processes, each with a different install, but you can't load two Python versions into the same Excel. PyXLL runs Python inside the Excel process, and one process can only host one Python interpreter.
We recommend keeping all the projects you use in Excel on the same Python version. Running two versions is best kept as a temporary measure, for example while testing an upgrade from Python 3.12 to 3.14.
Setting up a PyXLL install for each Python version
Install PyXLL once per Python version, each into its own folder. pyxll install downloads the build that matches the Python version you run it with.
To be sure which Python you are using, call it by its full path with python -m pyxll instead of the pyxll command. For example, for a Python 3.12 environment:
C:\path\to\py312-env\python.exe -m pip install pyxll C:\path\to\py312-env\python.exe -m pyxll install
Then repeat for your other environment, e.g. Python 3.14:
C:\path\to\py314-env\python.exe -m pip install pyxll C:\path\to\py314-env\python.exe -m pyxll install
When you install the second time, PyXLL warns you that it is already installed. Continue, and choose a different folder so the first install is kept. Each install is set up to use the Python environment that installed it.
Licensing: PyXLL is licensed per user. Having several installs on the same PC, used by the same person, is fine.
Sharing settings between installs
To avoid keeping two configs in sync by hand, put the common settings in one shared config file. Each install's pyxll.cfg loads it with the external_config setting.
How it merges: values in the external config override the same values in each install's pyxll.cfg. The exceptions are pythonpath, modules and external_config, which are appended to instead.
What goes where:
| Setting | Where it goes | Why |
|---|---|---|
[PYTHON] executable |
Each install's own pyxll.cfg
|
Each install needs an environment matching its Python version. In the shared file it would override both installs. |
[LOG] settings |
Each install's own pyxll.cfg
|
Each add-in should log to its own file, especially if both run at the same time. |
[PYTHON] pythonpath |
Shared config | The location of your source code is the same for both. |
[PYXLL] modules |
Shared config | The modules you want loaded are the same for both. |
| Other common settings | Shared config | Change once, picked up by both. |
For example, the Python 3.12 install's pyxll.cfg:
[PYXLL] external_config = C:\pyxll\shared\pyxll-shared.cfg [PYTHON] executable = C:\path\to\py312-env\pythonw.exe
The Python 3.14 install's pyxll.cfg is the same, except its executable points at the 3.14 environment. The shared file, C:\pyxll\shared\pyxll-shared.cfg:
[PYXLL]
modules =
my_functions
[PYTHON]
pythonpath =
.\srcRelative paths are resolved from the folder of the config file they appear in. Here, .\src means C:\pyxll\shared\src, not a folder next to either install. The shared config can also be on a network drive or at a URL.
Switching between Python versions
Use pyxll activate to choose which install Excel loads. It only switches the active add-in; it doesn't download anything or change any files or config.
- Close all Excel windows.
-
Activate the install you want:
python -m pyxll activate "C:\pyxll\py314"
- Start Excel.
pyxll activate can switch to an install built for a different Python version from the Python you run the command with. That install still has to be configured for an environment matching its own version (see above).
Tip: put the activate command and a line that starts Excel in a .bat file for each version, and make a desktop shortcut to each.
Running both versions at the same time
You can have both versions in use at once by running two separate Excel processes, each with a different PyXLL install loaded.
Opening Excel normally while it is already running doesn't start a new process; it just opens another window in the existing one. To start a separate process, run EXCEL.EXE with the /x switch.
- Start Excel with the first install active (e.g. Python 3.12).
-
Activate the second install. Excel is already running, so add
--force:python -m pyxll activate --force "C:\pyxll\py314"
-
Start a second, separate Excel process:
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" /x
Important: the Excel you close last decides what loads next time. Excel saves its list of add-ins when it closes. With two Excel processes open, whichever one closes last decides which PyXLL install loads the next time you start Excel, not whichever install you activated last. This is why pyxll activate normally refuses to run while Excel is open.
If Excel then starts with the wrong version, close all Excel windows, run pyxll activate (without --force) for the install you want, and start Excel again.
Troubleshooting
"pythonXXX.dll not found" when Excel starts. The active PyXLL add-in was built for a different Python version from the one in its config. Either:
- point
executablein that install'spyxll.cfgat an environment of the version it was built for, or - run
python -m pyxll installwith the Python you want to use, so the matching build is downloaded.
Excel loads the wrong PyXLL install. Close every Excel window, check Task Manager for leftover EXCEL.EXE processes, then run pyxll activate for the install you want. Run pyxll status to see which install is active.
Related documentation
-
PyXLL Command Line Tool (
install,activate,status) -
Python settings (
executable,pythonpath) -
PyXLL settings (
external_config) - Which version of Python can I use in Excel?
- Managing multiple PyXLL configs