<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Crear secuencias de órdenes Python con ScriptForge</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="es/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="es/bookmarks.js" defer></script><script type="text/javascript" src="es/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="es/text/shared/05/new_help.html"><div></div></a><a class="logo" href="es/text/shared/05/new_help.html"><p dir="auto">Ayuda de LibreOffice 25.2</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Módulo</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contenido</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Buscar en los marcadores del módulo elegido" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<noscript><div id="WarnJS"><h1 dir="auto">Active JavaScript en el navegador para mostrar las páginas de ayuda de LibreOffice.</h1></div></noscript>
<a id="bm_id41582391760114"></a>
<meta itemprop="keywords" content="Python scripts with ScriptForge">
<h1 id="hd_id461623364876507" dir="auto">
<a id="title"></a>Creating Python Scripts with <span class="literal">ScriptForge</span>
</h1>
<h2 id="hd_id361623410405420" dir="auto">Diferencias entre BASIC y Python</h2>
<p id="par_id41623410443946" class="paragraph" dir="auto">La <a target="_top" href="es/text/sbasic/shared/03/lib_ScriptForge.html">biblioteca ScriptForge</a> está disponible tanto para BASIC como para Python. La mayor parte de los servicios, los métodos y las propiedades actúan de idéntica manera en ambos lenguajes de programación. Sin embargo, debido a diferencias de funcionamiento entre ambos, los usuarios de <span class="literal">ScriptForge</span> deben estar al tanto de ciertas características de la biblioteca cuando se utiliza Python:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id551623410718241" class="listitem" dir="auto"><span class="emph">Methods and Property names:</span> In Python, all methods and properties can be used in lowercased, ProperCased or camelCased formats.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id741623411104297" class="listitem" dir="auto"><span class="emph">Arguments:</span> All keyword arguments passed on to methods are lowercased.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id441623411216354" class="listitem" dir="auto"><span class="emph">Dates:</span> All date objects are passed and returned as <span class="literal">datetime.datetime</span> native Python objects.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id891623411367669" class="listitem" dir="auto"><span class="emph">Arrays:</span> One-dimensional arrays are passed and returned as tuples (which is an immutable object). Two-dimensional arrays are passed and returned as tuples of tuples.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id981623411507442" class="listitem" dir="auto"><span class="emph">None:</span> Python's <span class="literal">None</span> keyword is equivalent to Basic's <span class="literal">Null</span>, <span class="literal">Empty</span> or <span class="literal">Nothing</span>.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id21623411611447" class="listitem" dir="auto"><span class="emph">UNO objects:</span> All UNO structures are exchanged between Basic and Python without any changes.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id651623412069496" class="listitem" dir="auto"><span class="emph">Debugging:</span> Whenever an error occurs in Python scripts that use <span class="literal">ScriptForge</span>, the error message provided by the Python execution stack displays the line of code that triggered the error. In Basic error messages do not display this information.</p>
</li>
</ul>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31623411828158" dir="auto">Visit <a target="_top" href="es/text/sbasic/python/main0000.html#">LibreOffice Python Scripts Help</a> for more information on Python scripting using LibreOffice.</p></div>
</div>
<br>
<h2 id="hd_id402623411150191" dir="auto">Editing Python scripts in IDEs</h2>
<p id="par_id111733745619796" class="paragraph" dir="auto">Python typing hints - relating to <span class="literal">ScriptForge</span> services public methods and properties - can be obtained from IDEs that support such facility. Visually, while editing a user script:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id471733745941570" class="listitem" dir="auto">hovering an object instance, a method or a property displays its detailed description.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id631733745943026" class="listitem" dir="auto">a "." after an object instance displays a drop-down box listing all available interfaces.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id471733745961810" class="listitem" dir="auto">brackets after a method-name start code-completion by displaying its arguments.</p>
</li>
</ul>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id571733746663339" dir="auto">Typing hints are displayed when editing methods and properties with propercase letters.</p></div>
</div>
<br>
<h2 id="hd_id391623411150080" dir="auto">Ejecutar secuencias Python en LibreOffice</h2>
<p id="par_id411623364895100" class="paragraph" dir="auto">Depending on what you intend to achieve, you may choose one of the following approaches to running Python scripts in LibreOffice:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id681623365274024" class="listitem" dir="auto"><span class="emph">Run Scripts inside the current LibreOffice process:</span> Python scripts are executed from within the LibreOffice process by using the <span class="menuitem">Tools - Macros - Run Macro</span> menu or the APSO extension to call user scripts stored in the Python scripts folder. You can also use the APSO Python shell to interactively run Python scripts.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id761623365278133" class="listitem" dir="auto"><span class="emph">Run Scripts separately from the LibreOffice process:</span> Python scripts are executed from an external process that connects to an ongoing LibreOffice process using a socket.</p>
</li>
</ul>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id631623365667011" dir="auto">If you plan to run scripts from inside the LibreOffice process, it is recommended to install the <a target="_blank" href="https://extensions.libreoffice.org/en/extensions/show/apso-alternative-script-organizer-for-python">APSO (Alternative Script Organizer for Python) extension</a>. However, to develop Python scripts from outside LibreOffice, you can choose your preferred Python IDE.</p></div>
</div>
<br>
<h2 id="hd_id431623365836802" dir="auto">Ejecutar secuencias dentro del proceso de LibreOffice</h2>
<h3 id="hd_id111623365861568" dir="auto">Utilizar la extensión APSO</h3>
<p id="par_id681623365892513" class="paragraph" dir="auto">The easiest way to get started with Python scripting in LibreOffice is by installing the APSO extension. After installing it, open any LibreOffice component and go to <span class="menuitem">Tools - Macros - Organize Python Scripts</span>.</p>
<p id="par_id111623366334727" class="paragraph" dir="auto">In APSO's main window go to <span class="menuitem">Menu - Python Shell</span>.</p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id931623366329927" dir="auto">Alternatively you can open APSO using the default shortcut <span class="keycode">Alt + Shift + F11</span>.</p></div>
</div>
<br>
<p id="par_id661623366478092" class="paragraph" dir="auto">Now you can start typing Python commands and the shell will print the corresponding output after each line of code is executed.</p>
<p id="par_id581623366559478" class="paragraph" dir="auto">To start using the <span class="literal">ScriptForge</span> library, you need to import the <span class="literal">CreateScriptService</span> method, with which you will be able to access the services provided by the library. The example below uses the <span class="literal">Basic</span> service to display a message box.</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
bas = CreateScriptService("Basic")
bas.MsgBox("Hello!")
</code></pre></div>
<p id="par_id701623366829587" class="paragraph" dir="auto">To run the example above, enter each line in the Python shell, one by one, pressing the Enter key after you type each line of code.</p>
<p id="par_id471623366906045" class="paragraph" dir="auto">Now you can start executing Python commands using any of the ScriptForge services. For example, the code snippet below uses the <span class="literal">UI</span> service to create a blank Writer document.</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui = CreateScriptService("UI")
doc = ui.CreateDocument("Writer")
</code></pre></div>
<h3 id="hd_id961623367376768" dir="auto">Crear archivos de secuencia de órdenes de Python</h3>
<p id="par_id821623367433650" class="paragraph" dir="auto">Puede crear sus propios archivos Python y modificarlos con su editor de texto predilecto. Después, puede llamarlos desde cualquier componente de LibreOffice.</p>
<p id="par_id51623367560321" class="paragraph" dir="auto">El primer paso consiste en encontrar la ubicación de las secuencias de órdenes de usuario. Para hacerlo, consulte la página de ayuda <a target="_top" href="es/text/sbasic/python/python_locations.html">Organización y ubicación de secuencias de órdenes Python</a>.</p>
<p id="par_id821623367773032" class="paragraph" dir="auto">Now you can create a text file inside your Python user scripts folder, for instance <span class="emph">sf_test.py</span>, and start typing your scripts.</p>
<p id="par_id271623367917630" class="paragraph" dir="auto">Next is a simple example that gets the numeric value from a Calc cell and increments it by 1. Simply type the following code into the <span class="emph">sf_test.py</span> file.</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
doc = CreateScriptService("Calc")
def increment_cell(args=None):
value = doc.GetValue("A1")
value += 1
doc.SetValue("A1", value)
g_exportedScripts = (increment_cell, )
</code></pre></div>
<p id="par_id171623368511426" class="paragraph" dir="auto">This example creates the <span class="literal">increment_cell</span> function. Note that <span class="literal">g_exportedScripts</span> is a tuple that tells which functions will be displayed in LibreOffice as user scripts.</p>
<p id="par_id471623368615244" class="paragraph" dir="auto">Para ejecutar esta secuencia desde un documento de Calc:</p>
<ol itemprop="HowTo" itemscope="true" itemtype="http://schema.org/HowToSection" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id811623368677444" class="listitem" dir="auto">Cree o abra un archivo de Calc.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id281623368679141" class="listitem" dir="auto">Enter some numeric value into cell "A1" in the current sheet.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id111623368679893" class="listitem" dir="auto">Diríjase a <span class="menuitem">Herramientas ▸ Macros ▸ Ejecutar macros</span>.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id421623368680565" class="listitem" dir="auto">Choose My Macros - sf_test in the library selector. Then choose the <span class="literal">increment_cell</span> function under the <span class="menuitem">Macro Name</span> list.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id131623368875763" class="listitem" dir="auto">Pulse en <span class="emph">Run</span> (‘Ejecutar’). Observe cómo el valor de la celda A1 aumenta en una unidad.</p>
</li>
</ol>
<p id="par_id781623368934689" class="paragraph" dir="auto">También puede utilizar APSO para ejecutar secuencias escritas en Python de manera semejante:</p>
<ol itemprop="HowTo" itemscope="true" itemtype="http://schema.org/HowToSection" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id501623369002537" class="listitem" dir="auto">Primeramente, abra APSO yendo a <span class="menuitem">Herramientas ▸ Macros ▸ Organizar secuencias de Python</span>.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id521623369004825" class="listitem" dir="auto">En la lista de macros, navegue a <span class="menuitem">Mis macros ▸ sf_test ▸ increment_cell</span>.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/HowToStep" dir="auto">
<p id="par_id101623369005929" class="listitem" dir="auto">Pulse en <span class="menuitem">Ejecutar</span>.</p>
</li>
</ol>
<h2 id="hd_id531623369208159" dir="auto">Ejecutar secuencias separadamente del proceso de LibreOffice</h2>
<a id="InstallPath"></a>
<h3 id="hd_id261623370168228" dir="auto">Determinar la ruta de la instalación</h3>
<p id="par_id261623369722023" class="paragraph" dir="auto">The first step to run scripts from a separate process is to find the folder where LibreOffice is installed. There are several ways to do that, but <span class="literal">ScriptForge</span> provides a quick way to identify your installation path. For that, open APSO's Python shell and type:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
fs = CreateScriptService("FileSystem")
fs.FileNaming = "SYS"
inst_dir = fs.InstallFolder
print(inst_dir)
</code></pre></div>
<p id="par_id81623370150730" class="paragraph" dir="auto">The output from the code above is the base directory where LibreOffice is installed. Now you need to add the "program" subfolder to the resulting path. This is the base folder from which you will run Python scripts from a separate process.</p>
<p id="par_id451623370201479" class="paragraph" dir="auto">For example, suppose you get <span class="emph">/usr/lib/libreoffice/</span> as the result from running the Python code above. Then you need to consider <span class="emph">/usr/lib/libreoffice/program</span> as the path to run your Python scripts.</p>
<h3 id="hd_id231623370501084" dir="auto">Start LibreOffice with socket settings</h3>
<p id="par_id721623369245475" class="paragraph" dir="auto">Para ejecutar las secuencias Python desde un proceso separado, es necesario iniciar LibreOffice con algunas opciones adicionales que especifican el nombre de anfitrión y el puerto a través del cual el proceso externo se comunicará con el proceso del componente de LibreOffice.</p>
<p id="par_id221623369584132" class="paragraph" dir="auto">Open the your operating system's command prompt, navigate to the program folder of your LibreOffice installation directory and type:</p>
<p id="par_id381623369456352" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">./soffice --accept='socket,host=localhost,port=2021;urp;'</span></p>
<p id="par_id981623370706743" class="paragraph" dir="auto">La orden anterior iniciará LibreOffice con una vía de comunicación abierta para que otros procesos puedan intercambiar mensajes con este.</p>
<p id="par_id621623370871360" class="paragraph" dir="auto">Observe que el ejemplo anterior abre el centro de bienvenida de LibreOffice. Si quiere abrir un componente en concreto, como por ejemplo Writer, puede añadir la opción --writer a la orden, como se ejemplifica a continuación:</p>
<p id="par_id371623370974348" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">./soffice --writer --accept='socket,host=localhost,port=2021;urp;'</span></p>
<p id="par_id431623373618951" class="paragraph" dir="auto">Tome nota de los parámetros <span class="literal">host</span> y <span class="literal">port</span>, los cuales en este ejemplo son <span class="emph">localhost</span> y <span class="emph">2021</span>, respectivamente.</p>
<h3 id="hd_id861623370468356" dir="auto">Ejecutar un intérprete de Python externo</h3>
<p id="par_id621623371253647" class="paragraph" dir="auto">Start the Python shell from within the <span class="emph">program</span> folder inside your LibreOffice installation path. Follow the steps <a target="_top" href="es/text/sbasic/shared/03/sf_intro.html#InstallPath">above</a> to learn how to find your installation path.</p>
<p id="par_id11623373098602" class="paragraph" dir="auto"><span class="emph">On Linux / Mac OS:</span></p>
<p id="par_id601623372243559" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">$ cd /usr/lib/libreoffice/program</span></p>
<p id="par_id601623372243336" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">$ python</span></p>
<p id="par_id311623373151552" class="paragraph" dir="auto"><span class="emph">En Windows:</span></p>
<p id="par_id601623372243204" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">$ cd C:\Program Files\LibreOffice\program\</span></p>
<p id="par_id601623372243399" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">$ python.exe</span></p>
<p id="par_id791623373520018" class="paragraph" dir="auto">This will open the Python shell and now you can start typing commands that will be executed by LibreOffice. But first you need to set up the socket connection.</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import ScriptForge, CreateScriptService
ScriptForge(hostname='localhost', port=2021)
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id761689720152565" dir="auto">Read the section <a target="_top" href="es/text/sbasic/shared/03/sf_intro.html#pythonpath">Setting PYTHONPATH</a> below in case of errors importing <span class="literal">scriptforge.py</span> or <span class="literal">uno.py</span>.</p></div>
</div>
<br>
<p id="par_id351623373686414" class="paragraph" dir="auto">The second line of code above defines the <span class="literal">host</span> and <span class="literal">port</span> settings so that the Python shell can communicate with an ongoing LibreOffice process opened with the same socket settings.</p>
<p id="par_id721623373769471" class="paragraph" dir="auto">Now you can run other Python commands and they will be able to communicate with the LibreOffice process. For example:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui = CreateScriptService("UI")
bas = CreateScriptService("Basic")
doc = ui.OpenDocument("~/Documents/myFile.ods")
bas.MsgBox(doc.DocumentType)
</code></pre></div>
<a id="bm_id631689720744160"></a> <meta itemprop="keywords" content="Python interpreter,PYTHONPATH">
<a id="pythonpath"></a>
<h3 id="hd_id341689720315095" dir="auto">Setting PYTHONPATH</h3>
<p id="par_id811689720328559" class="paragraph" dir="auto">Depending on your operating system's configuration you will need to set the environment variable <span class="literal">PYTHONPATH</span> in order to import the <span class="literal">scriptforge.py</span> library, which in turn requires importing the <span class="literal">uno.py</span> library.</p>
<p id="par_id781689720489355" class="paragraph" dir="auto">Use your operating system's file search tool to determine the directory where both these files are located.</p>
<p id="par_id431689720583565" class="paragraph" dir="auto">For instance, on a default Ubuntu installation both files may be located at:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id791689720632086" class="listitem" dir="auto"><span class="emph">scriptforge.py</span>: Located in <span class="literal">/usr/lib/libreoffice/program</span></p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id881689720632438" class="listitem" dir="auto"><span class="emph">uno.py</span>: Located in <span class="literal">/usr/lib/python3/dist-packages</span></p>
</li>
</ul>
<p id="par_id701689720782180" class="paragraph" dir="auto">In this case, set the environment variable <span class="literal">PYTHONPATH</span> as follows before starting the Python interpreter:</p>
<p id="par_id601689720825610" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">export PYTHONPATH=/usr/lib/libreoffice/program:/usr/lib/python3/dist-packages</span></p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id971689720909044" dir="auto">The location of these files will be different for each operating system and LibreOffice installation method.</p></div>
</div>
<br>
<a id="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a id="related"></a><span class="emph">Temas relacionados</span></p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/lib_ScriptForge.html">La biblioteca <span class="literal">ScriptForge</span></a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/python/main0000.html">Ayuda con las macros en Python en LibreOffice</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/shared/guide/start_parameters.html">Iniciar un programa de LibreOffice con parámetros</a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><h2 style="text-align: center;"><a href="https://books.libreoffice.org" target="_blank">Libros de LibreOffice</a></h2>
<div class="noteicon" dir="auto" style="display:flex;justify-content:center;flex-wrap:wrap;row-gap:15px;">
<img src="media/navigation/libo-writer.svg" alt="Writer Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-calc.svg" alt="Calc Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-impress.svg" alt="Impress Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-draw.svg" alt="Draw Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-base.svg" alt="Base Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-math.svg" alt="Math Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-symbol-black.svg" alt="Getting Started Icon" style="width:60px;height:60px;">
</div>
<div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_intro.xhp" target="_blank">/text/sbasic/shared/03/sf_intro.xhp</a></p>
<p dir="auto">Title is: Crear secuencias de órdenes Python con ScriptForge</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>