Difference between revisions of "Using Python on Linux"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Editorial changes attempting to clarify existing content)
m (OpenOffice.org on Internet)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Python is included on all major Linux distributions. However, this is what is referred to as a ''System Python'' and might not relate with the OpenOffice.org Python. The OOoPython is the one we need to know how to install and learn where it is. The location will vary depending on if you installed OOo from the [http://www.openoffice.org OpenOffice.org Site] or if it's coming from the distribution repository. This document will try to help you in identifying which OpenOffice.org Python is used within your setup.
+
Python is included on all major Linux distributions. However, this is what is referred to as a ''System Python'' and might not relate with the {{AOo}} Python. The OOoPython is the one we need to know how to install and learn where it is. The location will vary depending on if you installed {{AOo}} from the [https://www.openoffice.org OpenOffice.org Site] or if it's coming from the distribution repository. This document will try to help you in identifying which {{AOo}} Python is used within your setup.
  
=== OpenOffice.org on Internet ===
+
=== {{AOo}} on Internet ===
OpenOffice.org installation from the [http://www.openoffice.org|OpenOffice.org website] is usually the most common way to get the ''latest version'' of OOo, as distributions are not always quick to release the most recent version of the projects. OOo doesn't require many dependencies which makes it easy to install on any Linux system; however, guidance for the OOo installation process can be found [[installing|elsewhere]]. The focus here will be on how to locate and manage our OOo Python environment.
+
{{AOo}} installation from the [https://www.openoffice.org {{AOo}} website] is usually the most common way to get the ''latest version'' of {{AOo}}, as distributions are not always quick to release the most recent version of the projects. {{AOo}} doesn't require many dependencies which makes it easy to install on any Linux system; however, guidance for the {{AOo}} installation process can be found [[installing|elsewhere]]. The focus here will be on how to locate and manage our {{AOo}} Python environment.
  
The location for Python within OpenOffice.org from this type of installation is:
+
The location for Python within {{AOo}} from this type of installation is:
 
   /opt/openoffice.org2/program/python-core-2.3.4/
 
   /opt/openoffice.org2/program/python-core-2.3.4/
  
Line 18: Line 18:
 
We won't go over each script included, but it is important to acknowledge for a more in-depth study of the bridge.
 
We won't go over each script included, but it is important to acknowledge for a more in-depth study of the bridge.
  
=== OpenOffice.org on Debian ===
+
=== {{AOo}} on Debian ===
The Debian version of OpenOffice.org usually installs OOo under
+
The Debian version of {{AOo}} usually installs OOo under
 
     /usr/lib/openoffice/
 
     /usr/lib/openoffice/
  
The Debian OOo is built "--with-system-python", which means OOo Python is identical to your System Python.
+
The Debian {{AOo}} is built "--with-system-python", which means {{AOo}} Python is identical to your System Python.
  
 
[build log for debian stable (etch) available from http://buildd.debian.org/fetch.cgi?&pkg=openoffice.org&ver=2.0.4.dfsg.2-5etch2&arch=i386&stamp=1180841081&file=log]
 
[build log for debian stable (etch) available from http://buildd.debian.org/fetch.cgi?&pkg=openoffice.org&ver=2.0.4.dfsg.2-5etch2&arch=i386&stamp=1180841081&file=log]
  
=== OpenOffice.org on Fedora Core ===
+
=== {{AOo}} on Fedora Core ===
 
Fedora installs OpenOffice.org under:
 
Fedora installs OpenOffice.org under:
 
     /usr/lib/openoffice.org/
 
     /usr/lib/openoffice.org/
Line 32: Line 32:
 
The latest Fedora Core (release 8) ships with OpenOffice.org 2.3.0 as of this writing.
 
The latest Fedora Core (release 8) ships with OpenOffice.org 2.3.0 as of this writing.
  
Fedora basic installs don't provide OO.org Python support unless you specifically select the package for installation. Nonetheless, you could easily install it later by using ''yum'' from a terminal, or ''pup'' if you're more familiar with Gnome tools. The package name is: '''openoffice.org-pyuno'''.
+
Fedora basic installs don't provide {{AOo}} Python support unless you specifically select the package for installation. Nonetheless, you could easily install it later by using ''yum'' from a terminal, or ''pup'' if you're more familiar with Gnome tools. The package name is: '''openoffice.org-pyuno'''.
  
 
All Python scripts will be installed under the ''program'' folder.
 
All Python scripts will be installed under the ''program'' folder.
  
 
Fedora Core's PyUNO package doesn't install a Python runtime environment, because the official up-to-date Python distribution always gets installed, and you could use that version instead. You will have to set the ''PYTHONPATH'' environment variable to use Python outside of OO.org; if you don't, the ''python'' executable will not be able to locate the pyuno libraries. From a terminal type:
 
Fedora Core's PyUNO package doesn't install a Python runtime environment, because the official up-to-date Python distribution always gets installed, and you could use that version instead. You will have to set the ''PYTHONPATH'' environment variable to use Python outside of OO.org; if you don't, the ''python'' executable will not be able to locate the pyuno libraries. From a terminal type:
<code>[bash]
+
<syntaxhighlight lang="bash">
 
export PYTHONPATH="/usr/lib/openoffice.org/program"
 
export PYTHONPATH="/usr/lib/openoffice.org/program"
</code>
+
</syntaxhighlight>
 
before invoking ''python''.
 
before invoking ''python''.
  
=== OpenOffice.org on Ubuntu ===
+
=== {{AOo}} on Ubuntu ===
 +
==== Ubuntu 10 ====
 +
See Talk page; add here as appropriate.
 +
==== Ubuntu 6 ====
 
Ubuntu  installs OpenOffice.org under:
 
Ubuntu  installs OpenOffice.org under:
 
     /usr/lib/openoffice/  
 
     /usr/lib/openoffice/  
Line 48: Line 51:
 
Ubuntu 6.06, 'Dapper', installs OpenOffice.org Python package ''openoffice-uno'' by default.
 
Ubuntu 6.06, 'Dapper', installs OpenOffice.org Python package ''openoffice-uno'' by default.
  
The Ubuntu OOo is built "--with-system-python", which means OOo Python is identical to your System Python (This applies to the most recent stable version at the time of writing, which was 'Feisty').
+
The Ubuntu {{AOo}} is built "--with-system-python", which means {{AOo}} Python is identical to your System Python (This applies to the most recent stable version at the time of writing, which was 'Feisty').
  
 
All Python scripts will be installed under the ''program'' folder.
 
All Python scripts will be installed under the ''program'' folder.
  
You will have to set the ''PYTHONPATH'' environment variable to use Python outside of OO.org; if you don't, the ''python'' executable will not find the pyuno libraries. From a terminal type:
+
You will have to set the ''PYTHONPATH'' environment variable to use Python outside of {{AOo}}; if you don't, the ''python'' executable will not find the pyuno libraries. From a terminal type:
<code>[bash]
+
<syntaxhighlight lang="bash">
 
export PYTHONPATH="/usr/lib/openoffice.org/program"
 
export PYTHONPATH="/usr/lib/openoffice.org/program"
</code>
+
</syntaxhighlight>
 
before invoking ''python''.
 
before invoking ''python''.
  
[Build log for i386 available from http://launchpadlibrarian.net/7260728/buildlog_ubuntu-feisty-i386.openoffice.org_2.2.0-1ubuntu3_FULLYBUILT.txt.gz]
+
[Build log for i386 available from https://launchpadlibrarian.net/7260728/buildlog_ubuntu-feisty-i386.openoffice.org_2.2.0-1ubuntu3_FULLYBUILT.txt.gz]
  
'''Note:''' attempting to make use of UNO in a Python script fails until the following is done:
+
{{Note | attempting to make use of UNO in a Python script fails until the following is done:
  
 
                   sudo ldconfig -v /usr/lib/openoffice/program
 
                   sudo ldconfig -v /usr/lib/openoffice/program
 +
}}
  
  
 
+
[[Category:Python]][[Category:Linux]][[Category:Documentation]]
[[Category:Python]]
+

Latest revision as of 12:42, 3 February 2021

Python is included on all major Linux distributions. However, this is what is referred to as a System Python and might not relate with the Apache OpenOffice Python. The OOoPython is the one we need to know how to install and learn where it is. The location will vary depending on if you installed Apache OpenOffice from the OpenOffice.org Site or if it's coming from the distribution repository. This document will try to help you in identifying which Apache OpenOffice Python is used within your setup.

Apache OpenOffice on Internet

Apache OpenOffice installation from the Apache OpenOffice website is usually the most common way to get the latest version of Apache OpenOffice, as distributions are not always quick to release the most recent version of the projects. Apache OpenOffice doesn't require many dependencies which makes it easy to install on any Linux system; however, guidance for the Apache OpenOffice installation process can be found elsewhere. The focus here will be on how to locate and manage our Apache OpenOffice Python environment.

The location for Python within Apache OpenOffice from this type of installation is:

  /opt/openoffice.org2/program/python-core-2.3.4/

This implementation also includes some interesting Python scripts such as:

  • python.bin
  • pythonloader.py and pyc
  • uno.py and pyc
  • unohelper.py and pyc
  • mailmerge.py
  • officehelper

We won't go over each script included, but it is important to acknowledge for a more in-depth study of the bridge.

Apache OpenOffice on Debian

The Debian version of Apache OpenOffice usually installs OOo under

   /usr/lib/openoffice/

The Debian Apache OpenOffice is built "--with-system-python", which means Apache OpenOffice Python is identical to your System Python.

[build log for debian stable (etch) available from http://buildd.debian.org/fetch.cgi?&pkg=openoffice.org&ver=2.0.4.dfsg.2-5etch2&arch=i386&stamp=1180841081&file=log]

Apache OpenOffice on Fedora Core

Fedora installs OpenOffice.org under:

   /usr/lib/openoffice.org/

The latest Fedora Core (release 8) ships with OpenOffice.org 2.3.0 as of this writing.

Fedora basic installs don't provide Apache OpenOffice Python support unless you specifically select the package for installation. Nonetheless, you could easily install it later by using yum from a terminal, or pup if you're more familiar with Gnome tools. The package name is: openoffice.org-pyuno.

All Python scripts will be installed under the program folder.

Fedora Core's PyUNO package doesn't install a Python runtime environment, because the official up-to-date Python distribution always gets installed, and you could use that version instead. You will have to set the PYTHONPATH environment variable to use Python outside of OO.org; if you don't, the python executable will not be able to locate the pyuno libraries. From a terminal type:

export PYTHONPATH="/usr/lib/openoffice.org/program"

before invoking python.

Apache OpenOffice on Ubuntu

Ubuntu 10

See Talk page; add here as appropriate.

Ubuntu 6

Ubuntu installs OpenOffice.org under:

   /usr/lib/openoffice/ 

Ubuntu 6.06, 'Dapper', installs OpenOffice.org Python package openoffice-uno by default.

The Ubuntu Apache OpenOffice is built "--with-system-python", which means Apache OpenOffice Python is identical to your System Python (This applies to the most recent stable version at the time of writing, which was 'Feisty').

All Python scripts will be installed under the program folder.

You will have to set the PYTHONPATH environment variable to use Python outside of Apache OpenOffice; if you don't, the python executable will not find the pyuno libraries. From a terminal type:

export PYTHONPATH="/usr/lib/openoffice.org/program"

before invoking python.

[Build log for i386 available from https://launchpadlibrarian.net/7260728/buildlog_ubuntu-feisty-i386.openoffice.org_2.2.0-1ubuntu3_FULLYBUILT.txt.gz]

Documentation note.png attempting to make use of UNO in a Python script fails until the following is done:
                 sudo ldconfig -v /usr/lib/openoffice/program
Personal tools