Gnumeric-python plugin

Cannot get python macros to work with Gnumeric.

Have followed instructions here.

Gnumeric version:

$ gnumeric --version
gnumeric version '1.12.48'
datadir := '/usr/share/gnumeric/1.12.48'
libdir := '/usr/lib/gnumeric/1.12.48'

After enabling Python Console as described in 18.3.2.1. Enabling the Python Console and starting a python console:

>>> import 1Gnumeric
  File "<stdin>", line 1
    import 1Gnumeric
           ^
SyntaxError: invalid syntax
>>> 

This is not the same as the output shown in the instructions:

>>> import 1Gnumeric
>>> dir()
['Gnumeric', '__builtins__', '__doc__', '__name__']
>>> dir(Gnumeric)
['Boolean', 'CellPos', 'FALSE', 'GnumericError', 'GnumericErrorDIV0',
'GnumericErrorNA', 'GnumericErrorNAME', 'GnumericErrorNULL',
'GnumericErrorNUM', 'GnumericErrorRECALC', 'GnumericErrorREF',
'GnumericErrorVALUE', 'MStyle', 'Range', 'TRUE', '__doc__',
'__name__', 2'functions', 'plugin_info', 'workbook_new', 'workbooks']

Really could use some help here.

Welcome to the Forum!

You’re getting a SyntaxError after trying to import the Gnumeric module. The output indicates where the error is.

In the Python Console in Gnumeric use:

>>> import Gnumeric

(without the number 1) in order to import the Gnumeric module.

tried the following:

$ python
Python 3.8.5 (default, Sep  5 2020, 10:50:12) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Gnumeric
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Gnumeric'
>>> 

You state: “In the Python Console in Gnumeric use:”

After selecting “Python console” from “Tools” menu, I don’t get a Gnumeric console.

The console I launch is the standard linux Terminal ???

File: /usr/lib/gnumeric/1.12.48/plugins/python-loader/plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="Gnumeric_PythonLoader">
	<information>
		<name>Python plugin loader</name>
		<name xml:lang="ast">Cargador de complementos de Pyhton</name>
		<name xml:lang="bg">Програма за зареждане на модули на Python</name>
		<name xml:lang="bs">Sistem za učitavanje Pajton dodataka</name>
		<name xml:lang="ca">Carregador del connector del Python</name>
		<name xml:lang="ca@valencia">Carregador del connector del Python</name>
		<name xml:lang="cs">Zavaděč zásuvných modulů v jazyce Python</name>
		<name xml:lang="da">Python-udvidelsesmodulindlæser</name>
		<name xml:lang="de">Python-Plugin-Starter</name>
		<name xml:lang="dz">པ་ཡི་ཐོན་པ་ལག་ཨིན་མངོན་གསལ་འབད་མི་</name>
		<name xml:lang="el">Φορτωτής πρόσθετης λειτουργίας Python</name>
		<name xml:lang="en_CA">Python plugin loader</name>
		<name xml:lang="en_GB">Python plugin loader</name>
		<name xml:lang="es">Cargador de complementos de Pyhton</name>
		<name xml:lang="et">Pythoni pluginate laadija</name>
		<name xml:lang="eu">Python pluginen kargatzailea</name>
		<name xml:lang="fi">Python-liitännäislatain</name>
		<name xml:lang="fr">Chargeur de greffon Python</name>
		<name xml:lang="gl">Cargador de engadidos de Python</name>
		<name xml:lang="gu">Python પ્લગઇન લોડર</name>
		<name xml:lang="hr">Pokretač dodatka za Python</name>
		<name xml:lang="hu">Python bővítménybetöltő</name>
		<name xml:lang="id">Pemuat plugin Python</name>
		<name xml:lang="it">Caricatore del plugin Python</name>
		<name xml:lang="ja">Python プラグイン・ローダー</name>
		<name xml:lang="ko">파이썬 플러그인</name>
		<name xml:lang="lt">Python papildinių įkėlimas</name>
		<name xml:lang="lv">Python spraudņa ielādētājs</name>
		<name xml:lang="ms">Pemuat plugin Python</name>
		<name xml:lang="nb">Python tilleggslaster</name>
		<name xml:lang="ne">पाइथोन प्लगइन लोडर</name>
		<name xml:lang="nl">Python plugin lader</name>
		<name xml:lang="nn">Python tilleggsmodullastar</name>
		<name xml:lang="pl">Wczytywanie wtyczki języka Python</name>
		<name xml:lang="pt">Carregador de extensões Python</name>
		<name xml:lang="pt_BR">Carregador de plug-ins Python</name>
		<name xml:lang="ro">Extensie încărcare Python</name>
		<name xml:lang="ru">Загрузчик дополнения Python</name>
		<name xml:lang="sk">Load modulu Python</name>
		<name xml:lang="sl">Nalagalnik vstavkov Python</name>
		<name xml:lang="sr">Учитавач прикључка Питона</name>
		<name xml:lang="sr@latin">Učitavač priključka Pitona</name>
		<name xml:lang="sv">Inläsare för Python-insticksmoduler</name>
		<name xml:lang="tr">Python eklenti yükleyici</name>
		<name xml:lang="uk">Завантажувач доповнень Python</name>
		<name xml:lang="vi">Bộ tải bổ sung Python</name>
		<name xml:lang="zh_CN">Python 插件装入器</name>
		<name xml:lang="zh_HK">Python 外掛程式載入程式</name>
		<name xml:lang="zh_TW">Python 外掛程式載入程式</name>
		<description>This plugin provides support for Python plugins</description>
		<description xml:lang="ast">Esti complementu proporciona sofitu pa los complementos de Python</description>
		<description xml:lang="bg">Този модул осигурява поддръжка на модули на Python</description>
		<description xml:lang="bs">Ovaj dodatak obezbeđuje podršku za Pajton dodatke</description>
		<description xml:lang="ca">Aquest connector permet habilitar els connectors del Python</description>
		<description xml:lang="ca@valencia">Este connector permet habilitar els connectors del Python</description>
		<description xml:lang="cs">Tento zásuvný modul poskytuje podporu pro zásuvné moduly v jazyce Python</description>
		<description xml:lang="da">Dette udvidelsesmodul giver understøttelse af Python-udvidelsesmoduler</description>
		<description xml:lang="de">Dieses Plugin bietet Unterstützung für Python-Plugins</description>
		<description xml:lang="dz">འ་ནི་པ་ལག་ཨིན་འདི་གིས་ པ་ཡི་ཐོན་པ་ལག་ཨིནསི་གི་དོན་ལུ་ རྒྱབ་སྐྱོར་བྱིནམ་ཨིན་</description>
		<description xml:lang="el">Η πρόσθετη αυτή λειτουργία παρέχει υποστήριξη για πρόσθετες λειτουργίες Python</description>
		<description xml:lang="en_CA">This plugin provides support for Python plugins</description>
		<description xml:lang="en_GB">This plugin provides support for Python plugins</description>
		<description xml:lang="es">Este complemento proporciona soporte para los complementos de Python</description>
		<description xml:lang="eu">Python pluginetarako euskarria duzu plugin hau</description>
		<description xml:lang="fi">Tämä liitännäinen tarjoaa tuen Python-liitännäisille</description>
		<description xml:lang="fr">Ce greffon fournit une prise en charge pour les greffons en Python</description>
		<description xml:lang="gu">આ પ્લગઇન એ Python પ્લગઇનો માટે આધાર પૂરો પાડે છે</description>
		<description xml:lang="hr">Ovaj umetak omogućuje podršku za Python umetke</description>
		<description xml:lang="hu">Ez a bővítmény támogatást biztosít Python bővítményekhez</description>
		<description xml:lang="id">Plugin ini menyediakan dukungan untuk plugin Python</description>
		<description xml:lang="it">Questo plugin fornisce supporto per i plugin di Python</description>
		<description xml:lang="ja">このプラグインは Python プラグインのサポートを提供します</description>
		<description xml:lang="ko">이 플러그인은 파이썬 플러그인을 지원합니다</description>
		<description xml:lang="lt">Šis papildinys įjungia Python papildinių palaikymą</description>
		<description xml:lang="lv">Šis spraudnis sniedz Python spraudņu atbalstu.</description>
		<description xml:lang="ms">Plugin ini membekalkan sokongan bagi plugin Python</description>
		<description xml:lang="nb">Dette tillegget gir støtte for Python-tillegg</description>
		<description xml:lang="ne">पाइथोन प्लगइनका लागि यो प्लगइनले समर्थन प्रदान गर्छ</description>
		<description xml:lang="nl">Deze plugin levert ondersteuning voor Python plugins</description>
		<description xml:lang="nn">Denne tillegsmodules tilbyr støtte for Python tillgesmodular</description>
		<description xml:lang="pl">Ta wtyczka dostarcza obsługę wtyczek języka Python</description>
		<description xml:lang="pt">Esta extensão disponibiliza suporte para extensões Python</description>
		<description xml:lang="pt_BR">Este plug-in dá suporte a plug-ins Python</description>
		<description xml:lang="ro">Această extensie oferă suport pentru extensiile Python</description>
		<description xml:lang="ru">Это дополнение предоставляет поддержку для дополнений Python</description>
		<description xml:lang="sk">Tento modul poskytuje podporu pre moduly Python</description>
		<description xml:lang="sl">Vstavek omogoča podporo vstavkom Python</description>
		<description xml:lang="sr">Овај прикључак обезбеђује подршку за прикључке Питона</description>
		<description xml:lang="sr@latin">Ovaj priključak obezbeđuje podršku za priključke Pitona</description>
		<description xml:lang="sv">Denna insticksmodul tillhandahåller stöd för Python-insticksmoduler</description>
		<description xml:lang="tr">Bu eklenti Python eklentileri desteği sağlar</description>
		<description xml:lang="uk">Це доповнення надає підтримку доповнень на Python</description>
		<description xml:lang="vi">Bổ sung này hỗ trợ bổ sung Python</description>
		<description xml:lang="zh_CN">此插件提供了 Python 插件的支持</description>
		<description xml:lang="zh_HK">本增效模組提供 Python 增效模組的支援</description>
		<description xml:lang="zh_TW">本增效模組提供 Python 增效模組的支援</description>
		<require_explicit_enabling/>
	</information>
	<loader type="Gnumeric_Builtin:module">
		<attribute value="python_loader" name="module_file"/>
	</loader>
	<services>
		<service type="plugin_loader" id="python"/>
		<service type="ui" id="console" file="ui-console-menu.xml">
			<actions>
				<action name="ShowConsole">
					<label>Python console</label>
					<label xml:lang="bs">Konzola Pitona</label>
					<label xml:lang="ca">Consola de Python</label>
					<label xml:lang="cs">Konzola jazyka Python</label>
					<label xml:lang="de">Python-Eingabefenster</label>
					<label xml:lang="el">Κονσόλα Python</label>
					<label xml:lang="en_CA">Python console</label>
					<label xml:lang="en_GB">Python console</label>
					<label xml:lang="en">Python console</label>
					<label xml:lang="es">Consola Python</label>
					<label xml:lang="eu">Python kontsola</label>
					<label xml:lang="fi">Python-pääte</label>
					<label xml:lang="fr">Console Python</label>
					<label xml:lang="gl">Consola de Python</label>
					<label xml:lang="hr">Konzola za Python</label>
					<label xml:lang="hu">Python konzol</label>
					<label xml:lang="id">Konsol Python</label>
					<label xml:lang="ja">Pythonコンソール</label>
					<label xml:lang="ko">파이썬 콘솔</label>
					<label xml:lang="lt">Python terminalas</label>
					<label xml:lang="lv">Python konsole</label>
					<label xml:lang="ml">പൈതണ് കണ്സോള്</label>
					<label xml:lang="ms">Konsol Python</label>
					<label xml:lang="nb">Python-konsoll</label>
					<label xml:lang="pl">Konsola języka Python</label>
					<label xml:lang="pt">Consola Python</label>
					<label xml:lang="pt_BR">Console Python</label>
					<label xml:lang="ru">Консоль Python</label>
					<label xml:lang="sk">Konzola Python</label>
					<label xml:lang="sl">Konzola Python</label>
					<label xml:lang="sr">Конзола Питона</label>
					<label xml:lang="sr@latin">Konzola Pitona</label>
					<label xml:lang="sv">Pythonkonsol</label>
					<label xml:lang="tr">Python konsolu</label>
					<label xml:lang="uk">Консоль «Python»</label>
					<label xml:lang="zh_CN">Python 控制台</label>
					<label xml:lang="zh_HK">Python 主控台</label>
					<label xml:lang="zh_TW">Python 主控台</label>
				</action>
			</actions>
		</service>
	</services>
</plugin>
File: /usr/lib/gnumeric/1.12.48/plugins/python-loader/ui-console-menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<ui>
  <menubar>
    <menu name="Tools" action="MenuTools">
      <menuitem action="ShowConsole"/>
    </menu>
  </menubar>
</ui>

Did you delete the 5 lines?
You just only need to uncomment, I think.

  1. Edit python-loader/plugin.xml.
  2. Uncomment the five lines starting with ui-console-menu service near the bottom (remove the “” tags around the <service…> and tags.

None of the xml tags are commented in file: /usr/lib/gnumeric/1.12.48/plugins/python-loader/plugin.xml

Does PyCharm need to be installed?

Ah, Sorry I mean this lines:

< /loader>
services
service type=“plugin_loader” id=“python”/
service type=“ui” id=“console” file=“ui-console-menu.xml”



Python 主控台


/service
/services
< /plugin>

and follow the other step from Programming Gnumeric using Python .

But none of the lines are commented:
	<loader type="Gnumeric_Builtin:module">
		<attribute value="python_loader" name="module_file"/>
	</loader>
	<services>
		<service type="plugin_loader" id="python"/>
		<service type="ui" id="console" file="ui-console-menu.xml">
			<actions>
				<action name="ShowConsole">
					<label>Python console</label>
					<label xml:lang="bs">Konzola Pitona</label>
					<label xml:lang="ca">Consola de Python</label>
					<label xml:lang="cs">Konzola jazyka Python</label>
					<label xml:lang="de">Python-Eingabefenster</label>
					<label xml:lang="el">Κονσόλα Python</label>
					<label xml:lang="en_CA">Python console</label>
					<label xml:lang="en_GB">Python console</label>
					<label xml:lang="en">Python console</label>
					<label xml:lang="es">Consola Python</label>
					<label xml:lang="eu">Python kontsola</label>
					<label xml:lang="fi">Python-pääte</label>
					<label xml:lang="fr">Console Python</label>
					<label xml:lang="gl">Consola de Python</label>
					<label xml:lang="hr">Konzola za Python</label>
					<label xml:lang="hu">Python konzol</label>
					<label xml:lang="id">Konsol Python</label>
					<label xml:lang="ja">Pythonコンソール</label>
					<label xml:lang="ko">파이썬 콘솔</label>
					<label xml:lang="lt">Python terminalas</label>
					<label xml:lang="lv">Python konsole</label>
					<label xml:lang="ml">പൈതണ് കണ്സോള്</label>
					<label xml:lang="ms">Konsol Python</label>
					<label xml:lang="nb">Python-konsoll</label>
					<label xml:lang="pl">Konsola języka Python</label>
					<label xml:lang="pt">Consola Python</label>
					<label xml:lang="pt_BR">Console Python</label>
					<label xml:lang="ru">Консоль Python</label>
					<label xml:lang="sk">Konzola Python</label>
					<label xml:lang="sl">Konzola Python</label>
					<label xml:lang="sr">Конзола Питона</label>
					<label xml:lang="sr@latin">Konzola Pitona</label>
					<label xml:lang="sv">Pythonkonsol</label>
					<label xml:lang="tr">Python konsolu</label>
					<label xml:lang="uk">Консоль «Python»</label>
					<label xml:lang="zh_CN">Python 控制台</label>
					<label xml:lang="zh_HK">Python 主控台</label>
					<label xml:lang="zh_TW">Python 主控台</label>
				</action>
			</actions>
		</service>
	</services>

There is nothing to un-comment…

A commented xml tag would appear as:

<!--service type="ui" id="console" file="ui-console-menu.xml"-->

Installed Gnumeric on Knoppix and was able to launch the Python console from within Gnumeric.

The only problem was not being able to load local python macros I wrote.

So there is a problem with the manjaro installation. Maybe a permission problem.

A few Gnumeric revisions ago, all my python macros worked.

But now, can’t get any of them to work ???

Yes, that is mentioned in the page you linked in your first post.

The Gnumeric module isn’t installed system-wide, but only for the program Gnumeric and you can only use it from the Python interpreter from inside Gnumeric.
That’s the reason you get this error when you’re using the Python interpreter from your terminal emulator:

As you already found out

I get the same behaviour after installing the latest version of Gnumeric from the repos.

If you launch Gnumeric from the terminal (gnumeric) and try to open the Python console, you’ll get this output

and the Python console doesn’t open.

The exact same issue was also reported in the Solus Forums, which makes me think that the issue isn’t specific to Arch/Manjaro (Gnumeric is a package that comes from Arch).

I would suggest to report this issue to the developers, so that they can have a look at it.

2 Likes

@bill_t ,

I should have done exactly what you did by launching gnumeric from the terminal and then attempt to load the Python console to see the error reported in the terminal.

Was able to get Python console together with my python macros working in version 1.12.44 in MX Linux.

Will post this issue with the developers.

Appreciate your help.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.