Python Scripts Organization

Contents
Index 🔎︎

# Python Scripts Organization and Location

The Python script files are stored in the filesystem, in folders controlled by LibreOffice. The macros can be started at installation, user or file level.

## Python Script Locations

Refer to Getting Session Information in order to get programmatic access to Python script locations.

### LibreOffice Macros container

Existing macros in this location (container) were copied by the installation program and are available to every computer user, and any open document can access macros stored the container. You need administrative rights to store or edit macros here.

The LibreOffice Macros container location in the file system depends on the operating system:

- For Windows: {Installation}\share\Scripts\python.

- For Linux and macOS: {Installation}/share/Scripts/python.

### My Macros

This container is accessible only by the LibreOffice user. Any open document can access macros stored the container. Macros in this location are stored in the LibreOffice user profile.

The My Macros container location is in the user space and depends on the operating system:

- For Windows,
  %APPDATA%\LibreOffice\4\user\Scripts\python.

- For Linux and macOS,
  $HOME/.config/libreoffice/4/user/Scripts/python.

### Document macros

Document macros are embedded in the document and are accessible only when the document is open.

## Libraries, Modules and Macros

Like BASIC macros, Python macros can be organized in libraries, modules and macros.

### Creating a Python Library

Libraries are folders in the container tree. To create a library, add a folder in the target container. The library name is the folder name.

### Creating a Python Module.

A module is a python file in the library or the container. Create a module adding a file in the container.

### Python macros

A macro is a python object in the module.

Related Topics

Getting Session Information

LibreOffice Python Scripts Help