TL;DR;
Activate your conda environment and follow the usual installation instructions.
If installing or configuring PyXLL manually, set “executable” in the PYTHON section of your pyxll.cfg config file to the Python executable in the conda env you’re using, e.g.
[PYTHON]
executable = C:\Program Files\Anaconda\envs\pyxll\pythonw.exe
Anaconda is an open source Python distribution that aims to simplify Package management and distribution.
The Anaconda distribution includes over a thousand Python packages as well as its own package and virtual environment manager, Conda.
For users wanting just the package and virtual environment manager, Conda, without the large download and install size of the full Anaconda distribution, there is also Miniconda.
Both Anaconda and Miniconda work well with PyXLL.
For more details about Anaconda see https://www.anaconda.com.
PyXLL will work fine with any Anaconda or Miniconda distribution for Windows. Note that PyXLL only supports Microsoft Windows and will not work on macOS.
When downloading Anaconda you are given the choice between Python 2 and Python 3. All current Python versions are supported by PyXLL, and so you are free to choose whichever version is right for you.
The Anaconda download page also offers the choice between a 64 bit installer and a 32 bit installed. The 64 bit installer is the default selection, but which one you need depends on the version of Excel you are using.
It is not possible to use a 64 bit Python environment with the 32 bit version of Excel.
To determine which version of Excel you are using, in Excel go to File -> Account -> About.
If your Excel version does not inclide “64-bit” as shown above, you are using the 32 bit version of Excel and will need to download the 32 bit version of Anaconda or Miniconda.
When using Anaconda or Miniconda it’s recommended to work within a virtual environment.
A virtual environment is a Python environment where you can install and update packages without modifying the base Python install. You can have multiple environments at any time, so you could have a virtual environment dedicated to everything you do in Excel with PyXLL without having to change any other environments you might have for other tasks.
Virtual environments are created using the “conda create” command.
For example, to create a Python 3.7 environment for use with PyXLL named “pyxll”, start an Anaconda command prompt and run the following:
>> conda create -n pyxll python=3.7
This will create a new Python 3.7 environment called “pyxll” (the name can be anything, it doesn’t have to be pyxll).
You then have to activate that environment and install the packages you want:
>> activate env
>> conda install pandas
To see what environments you have, use “conda info –envs”. That will give you the path to where the new pyxll environment has been created.
For more information about conda and virtual envs see Getting started with conda.
PyXLL can be used with the Anaconda and Miniconda distributions. Use of either a virtual env or the base Python environment is supported.
Follow the installation instructions to install PyXLL.
If you are using the PyXLL Command Line Tool then be sure to activate your conda environment first.
(base) >> activate env
(env) >> pip install pyxll
(env) >> pyxll install
If you are installing the PyXLL add-in manually then edit your pyxll.cfg file so that the executable setting references the Python executable from your conda environment:
[PYTHON]
executable = C:\Program Files\Anaconda\envs\pyxll\pythonw.exe
To determine what Python executable to use, open an Anaconda Command prompt and activate the virtual environment you want to use and type “where pythonw”:
(base) >> activate env
(env) >> where pythonw
C:/Program Files/Anaconda/envs/env/pythonw.exe
To change the virtual environment that PyXLL uses from the one your originally configured, simply update your pyxll.cfg config file to use the new virtual env and restart Excel.
Don’t forget that you may also need to install the pyxll stubs package in the new virtual environment if you require code completion in your IDE, or if you are importing pyxll outside of Excel for any other reason.