Python Environments

Note

The Python environment can only be set on the first call to RegisterPyModule(). Excel needs to be restarted to change the environment after modules have been registered.

Bundled Python

xlSlim is bundled with Python 3.10 This bundled version is installed when xlSlim starts. Usually this is installed at %HOMEPATH%AppDataLocal The bundled installation contain the Python standard library only, this excludes common packages such as requests, numpy and pandas.

You can always revert to using the bundled Python by running ClearSavedPythonEnv()

External Python environments

For more advanced Python functionality you can use external Python environments. xlSlim supports Python 3.7, 3.8, 3.9 and 3.10. xlSlim supports default Python installations as well as virtual environments created with venv or conda.

External Python environments are set when RegisterPyModule() is called. The ExecutablePath parameter is used to set the location of the Python executable.

As an example, this registers the numpy.py module from numpy Arrays for use with the conda Python 3.9 environment at “c:\users\russe\anaconda3\envs\py39”

=RegisterPyModule("c:\users\russe\documents\numpy.py","c:\users\russe\anaconda3\envs\py39")
Register xlSlim with conda Py39

Note

The last ExecutablePath value used is stored so you don’t need to include ExecutablePath after the first call to RegisterPyModule().

Full details of the Python environment being used can be viewed with PythonDetails(), this shows that xlSlim is using the conda Python 3.9 environment as expected.

Show Python details for conda Py39 env