Skip to content
This repository was archived by the owner on Aug 20, 2023. It is now read-only.

A Scripting Framework error occurred while executing the Python script #29

Open
pafpm opened this issue Aug 31, 2018 · 47 comments
Open

Comments

@pafpm
Copy link

pafpm commented Aug 31, 2018

It seems I installed correctly the Code Highlighter. I followed all steps on installation. But when I select the text on Impress and choose to highlight a Python code, the following error happens:

A Scripting Framework error occurred while executing the Python script
vnd.sun.star.script:codehighlighter.oxt|python|highlight.py$highlight_python3_default?language=Python&location=user:uno_packages.

Mensagem: <class 'KeyError'>: 'codehighlighter.oxt'
File "/usr/lib/libreoffice/program/pythonscript.py", line 993, in getScript
self.provCtx.uriHelper.getStorageURI(scriptUri) );
File "/usr/lib/libreoffice/program/pythonscript.py", line 381, in getStorageUrlFromPersistentUrl
package = self.mapPackageName2Path[ packageName ]

@Schweineschwarte
Copy link

Same here.
My system:

  • Ubuntu 18.04 LTS
  • Libreoffice:

Version: 6.0.6.2
Build-ID: 1:6.0.6-0ubuntu0.18.04.1
CPU-Threads: 4; BS: Linux 4.15; UI-Render: Standard; VCL: gtk3;
Gebietsschema: de-DE (de_DE.UTF-8); Calc: group

  • Python 3.6.6
  • pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
  • Pygments (2.2.0) [installed with pip3 like the documentation]

@jove1
Copy link

jove1 commented Dec 10, 2018

Same here:
Ubuntu 16.04 LTS
LibreOffice 5.4.6.2 40m0(Build:2)

ii  libreoffice                                   1:5.4.6~rc2-0ubuntu0.16.04. amd64                       office productivity suite (metapackage)
ii  libreoffice-script-provider-python            1:5.4.6~rc2-0ubuntu0.16.04. all                         Python script support provider for LibreOffice scripting framework
ii  python3-pygments                              2.1+dfsg-1                  all                         syntax highlighting package written in Python 3

@samyon196
Copy link

Same here:
Ubuntu 18.10
Libreoffice 6.1.3

@slgobinath
Copy link
Owner

Please check the latest release v1.5.

@JoseOlin
Copy link

Same here (with v1.5)
Linux Mint 18.1
LO: 6.1.4.2

@slgobinath
Copy link
Owner

@JLuisGT could you please give some more information?

  1. Does it occur only in LO Impress or in Writer too?
  2. Does it occur when you select a code and try to highlight or when you select the text box (as given in How to use and try to highlight?
  3. Could you please share the screenshot of the error message?

@JoseOlin
Copy link

Hi @slgobinath It's very attentive of you to answer this fast!

  1. It happens in both Impress and Writer.

  2. It happens both, selecting the code AND selecting a text box with the code inside.

  3. For sure!
    Impress Error
    Writer error

@slgobinath
Copy link
Owner

Hi,
May I know how you installed the extension? Did you install it only for the current user or for all users?

@JoseOlin
Copy link

JoseOlin commented Feb 1, 2019

Hi, @slgobinath

I don't really know. I just close all the LO products and make the Ubuntu derivatives installation, as recommended.

$ sudo apt-get install libreoffice-script-provider-python
$ sudo pip3 install pygments

How can I check if I made a current or all users installation?

Best regards.

@slgobinath
Copy link
Owner

Hi,
Though I couldn't reproduce this error, it affects other platforms as well: #25, #26, #28

@ruben1981 fixed the problem by copying the pygments folder to /usr/lib/libreoffice/program folder.
You can find the location of pygments module by running the following code in Python 3:

import pygments
print(pygments.__file__)

In my case the output is /usr/local/lib/python3.6/dist-packages/pygments/__init__.py.

To copy this module, enter the following command:

sudo cp -r /usr/local/lib/python3.6/dist-packages/pygments /usr/lib/libreoffice/program/

@JoseOlin
Copy link

JoseOlin commented Feb 3, 2019

Hi, @slgobinath

I try your suggestion without luck. In my case pygments is in /usr/lib/python3/dist-packages/pygments.

Just as a note: I also try refreshing the user profile, giving that another extension (TexMaths) wasn't working as well. After the refreshing, TexMaths is working but no luck with this handy extension.

I'll keep trying and thanks a lot for your patience.

@slgobinath
Copy link
Owner

When you install the extension did you get the option to install it for only you or for all users? If so, please install it only for you and see if it works.

In my case, I am using LM 19.1 and LO 6.0.7.3 with no problem. I will give a try with the latest LO and let you know.

@rzr
Copy link

rzr commented Mar 18, 2019

I am commenting for myself because I am hitting this issue over again, if text is selected instead of container it will crash. So I guess if there is no container selected but some text, the script should resolve to current container before processing.

@tronifier
Copy link

[SOLVED] In the documentation, it was written to install the following packages:
$ sudo apt-get install libreoffice-script-provider-python
$ sudo pip3 install pygments

If you are still getting the error, try installing 'python3-pygments':
$sudo apt install python3-pygments

@sakateka
Copy link

sakateka commented May 15, 2019

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt

Have a good day!

@silviulaurentiu
Copy link

I also have the same error:
image
on Windows 10, x64, libreoffice 6.1.5.2 and I install the extension using codehighlighter.oxt file.

@DevRThakkar
Copy link

DevRThakkar commented Aug 2, 2019

SOLVED (WINDOWS 10)

Go to --> "C:\Users\ {Your Username} \AppData\Local\Programs\Python\Python37\Lib\site-packages"
And copy "pygments" and "Pygments-2.4.2.dist-info" folders.
Now go to ---> "C:\Program Files\LibreOffice\program\python-core-3.5.7\lib\site-packages"
And paste both of these folders here.

That's it, Done.

@KasperFyhn
Copy link

KasperFyhn commented Aug 31, 2019

On Ubuntu 18.04, I managed to fix the issue by installing LibreOffice with apt-get instead of snap. Not sure what the issue was or if it was even related to that, but it might be worth a try.

@therayvoice
Copy link

I had the same issue but it was solved once I installed python3-pygments, python3-pip, etc. using sudo apt install package

@Mohaymin
Copy link

Hi,
May I know how you installed the extension? Did you install it only for the current user or for all users?

hello @slgobinath
I had issues similar to @JLuisGT . At first I installed the extension for all users and encountered this error. However, after removing the extension and then installing it for current user solved my problem. But before that I copied pygments folder to ..\LibreOffice\program\python-core-3.5.7\lib\site-packages

@droumanet
Copy link

I also have the same error:
image
on Windows 10, x64, libreoffice 6.1.5.2 and I install the extension using codehighlighter.oxt file.

Similar, with Version: 6.3.3.2 (x64)
Build ID: a64200df03143b798afd1ec74a12ab50359878ed
Threads CPU : 4; OS : Windows 10.0; UI Render : par défaut; VCL: win;
Locale : fr-CH (fr_FR); Langue IHM : fr-FR
Calc: threaded

@weleoka
Copy link

weleoka commented Nov 9, 2019

Can't contribute much to this issue right now. I've had the same troubles however and just documenting what I've done so far.

A short note about installing Pygments from Debian repositories, or the likes, is that it will probably be a much older version of Pygments than is available with pip, so maybe pip3 install pygments is better than apt install python3-pygments.

Anyway, the following creates the failures: installing codehighlighter with sudo unopkg gui --shared and then installing it for all users, then trying to tun the extension raises the error. Also running libreOffice as root raises the same error. Installing it for one user does the same. Adding it in normal ways... well, i've tried numerous combinations and always manage to get the error. Also having a textbox or not etc eems to not influence the issue.

With DEBUG in pythonloader.py and pythonscript.py this is the error when starting Writer to then using the extension:

Sat Nov  9 19:43:57 2019 [DEBUG] inspecting package codehighlighter.oxt(javahelps.codehighlighter)
Sat Nov  9 19:43:57 2019 [ERROR] adding Package lu5379rx1ckq.tmp_ ('file:///var/spool/libreoffice/uno_packages/cache/uno_packages/lu5379rx1ckq.tmp_/codehighlighter.oxt/python',)

...

Sat Nov  9 19:44:30 2019 [DEBUG] getScript vnd.sun.star.script:codehighlighter.oxt|python|highlight.py$create_dialog?language=Python&location=user:uno_packages invoked
Sat Nov  9 19:44:30 2019 [DEBUG] converting scriptURI=vnd.sun.star.script:codehighlighter.oxt|python|highlight.py$create_dialog?language=Python&location=user:uno_packages to storageURI=file:///home/user/.config/libreoffice/4/user/uno_packages/cache/uno_packages/codehighlighter.oxt/python/highlight.py$create_dialog
Sat Nov  9 19:44:30 2019 [ERROR] <class 'KeyError'>: 'codehighlighter.oxt'
  File "/usr/lib/libreoffice/program/pythonscript.py", line 1052, in getScript
    self.provCtx.uriHelper.getStorageURI(scriptUri) );
  File "/usr/lib/libreoffice/program/pythonscript.py", line 422, in getStorageUrlFromPersistentUrl
    package = self.mapPackageName2Path[ packageName ]

The following is debug output when adding the extension. This is from the unopkg gui program when extension is not installed through to it apparently being "installed":

ERROR: (com.sun.star.lang.IllegalArgumentException) { { { Message = "There is no such extension deployed: javahelps.codehighlighter", Context = (com.sun.star.uno.XInterface) @588a8d52a5a0 } }, ArgumentPosition = (short) -1 }

pythonloader.Loader ctor
pythonloader.Loader.activate
pythonloader: interpreting url vnd.openoffice.pymodule:pythonscript
pythonloader: after expansion vnd.openoffice.pymodule:pythonscript
Sat Nov  9 19:54:13 2019 [DEBUG] pythonscript loading
Sat Nov  9 19:54:13 2019 [DEBUG] pythonscript finished initializing
Fetched ImplHelper as <unohelper.ImplementationHelper object at 0x7f73c4491e10>
Sat Nov  9 19:54:13 2019 [DEBUG] Entering PythonScriptProvider.ctorshare:uno_packages
Sat Nov  9 19:54:13 2019 [DEBUG] initialized urihelper with baseUri=file:///var/spool/libreoffice/uno_packages/cache/uno_packages,m_scriptUriLocation=share:uno_packages
Sat Nov  9 19:54:13 2019 [DEBUG] got urlHelper <pythonscript.MyUriHelper object at 0x7f73c4454b00>
Sat Nov  9 19:54:13 2019 [DEBUG] share:uno_packages transformed to file:///var/spool/libreoffice/uno_packages/cache/uno_packages
Sat Nov  9 19:54:13 2019 [DEBUG] pythonscript: getPackageName2PathMap start getDeployedPackages
Sat Nov  9 19:54:13 2019 [DEBUG] pythonscript: getPackageName2PathMap end getDeployedPackages (1)
Sat Nov  9 19:54:13 2019 [DEBUG] inspecting package codehighlighter.oxt(javahelps.codehighlighter)
Sat Nov  9 19:54:13 2019 [ERROR] adding Package lu5744rxgwow.tmp_ ('file:///var/spool/libreoffice/uno_packages/cache/uno_packages/lu5744rxgwow.tmp_/codehighlighter.oxt/python',)
Sat Nov  9 19:54:13 2019 [DEBUG] hasByName called vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages/lu5744rxgwow.tmp_/codehighlighter.oxt/python
Sat Nov  9 19:54:13 2019 [DEBUG] hasByName file:///var/spool/libreoffice/uno_packages/cache/uno_packages/lu5744rxgwow.tmp_/codehighlighter.oxt/python True

Reading the thread it seems that various combinations of copying pygments around manually or installing extension globally or for only single user will make the problem go away. Anyone have any further ideas, or where to look for clues?

pip 18.1-5
Pygments 2.4.2
libreoffice (debian) 1:6.3.3-2~bpo10+1 (VLC is GTK3)
libreoffice-script-provider-python 1:6.3.3-2~bpo10+1 (installed automatically as dependency)
Linux 4.19, Debian 10
OpenJDK Runtime Environment (build 11.0.5+10-post-Debian-1deb10u1)

@weleoka
Copy link

weleoka commented Nov 11, 2019

After more research I find that this is most likely to do with the maintainer not wanting to maintain two versions of the extension for all users and only installed for single user.

There is an extensive discussion on this at: Document Foundation Bug #100307. It is essentially an added workload to make the Addons.xcu file compatible with all or individual users.

It also seems to be an issue worsened by a bug in the libreoffice core that isn't quite pinned down as yet.... because ideally core or Unopkg should warn about this in a friendly way.

To install this extension and use it - this is the process that worked for me:

sudo install python3-pip
sudo pip3 install pygments
unopkg gui
# Add the .oxt file and only for single current user if asked

Then it should work. Good luck.

@mertdot
Copy link

mertdot commented Apr 1, 2020

On Ubuntu 18.04, I managed to fix the issue by installing LibreOffice with apt-get instead of snap. Not sure what the issue was or if it was even related to that, but it might be worth a try.

I agree you, i've searched tons of web pages but only this comment solved my problem. Thank you :)

@yneuma
Copy link

yneuma commented May 28, 2020

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt

Have a good day!

For me the solving hint. It was not because of downloading it multiple times, but download file had an additional prefix: ea4db15f_codehighlighter.oxt. After renaming it works on my system.

@rzr
Copy link

rzr commented May 28, 2020

Maybe this error popup should display a link to this ticket :)

@ArenT1981
Copy link

Kudos to @yneuma , renaming the extension fixed it for me on my Fedora 32 system. I'd tried manually copying the pygments folder etc, but it turns out the default filename of the package after you download it from the extensions website is the problem.

So get rid of the ea4db15f_ in the package filename...

@wizzwizz4
Copy link

I have no idea why this happens (the lookup should be based on internal extension name, not installation filename), but I can confirm that the renaming fixes it. I had a non-working install, and:

  1. Renamed the file in my /tmp/mozilla_username0/ folder to remove the prefix.
  2. Removed the extension from LibreOffice Writer.
  3. Double-clicked on the extension in pcmanfm.
  4. Clicked "install".
  5. Clicked "accept".
  6. Restarted LibreOffice Writer.

And it worked, all of a sudden. Nothing else in my system changed.

@william-e
Copy link

Renaming the installation file solved the scripting framework error for me too.
This should probably make its way into the installation instructions on the Extension page ;)

@alvaro1553
Copy link

Renaming the installation file worked for me!

@AliN11
Copy link

AliN11 commented Sep 13, 2020

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt
Have a good day!

For me the solving hint. It was not because of downloading it multiple times, but download file had an additional prefix: ea4db15f_codehighlighter.oxt. After renaming it works on my system.

Fixed after renaming it to codehighlighter.oxt

@nuschpl
Copy link

nuschpl commented Oct 7, 2020

Above it's not true, I have it in codehighlighter.oxt the same issue. The issue is with local python installation can't be found and there are no instruction how to install it properly. The package libreoffice-script-provider-python installs strange wrappers:
$ dpkg-query -L libreoffice-script-provider-python /. /usr /usr/lib /usr/lib/libreoffice /usr/lib/libreoffice/program /usr/lib/libreoffice/program/pythonscript.py /usr/lib/libreoffice/program/services /usr/lib/libreoffice/program/services/scriptproviderforpython.rdb /usr/share /usr/share/bug /usr/share/bug/libreoffice-script-provider-python /usr/share/bug/libreoffice-script-provider-python/control /usr/share/bug/libreoffice-script-provider-python/presubj /usr/share/doc /usr/share/doc/libreoffice-script-provider-python
Some python packages in the path /usr/lib/libreoffice/program are installed by libreoffice-common:
$ dpkg -S /usr/lib/libreoffice/program/mailmerge.py libreoffice-common: /usr/lib/libreoffice/program/mailmerge.py
So if this seperate python path is for a reason we need way to upgrade it's modules - suggestion to copy pygments package from system path to here is perfect way to have more issues like this in future. And this at least should handle the error in more clear way.

@ovidiogm
Copy link

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt

Have a good day!

Thank you!!! that works for me!

@zackwhit
Copy link

After experimenting a bit, I discovered that, when installing, the file name had to be named exactly codehighlighter.oxt. When downloaded from https://extensions.libreoffice.org/en/extensions/show/code-highlighter, an additional string is tacked onto the beginning of the text. It doesn't appear necessary to do anything else except install the dependencies with the recommended commands.

System: Ubuntu 18.04.4 LTS
Libreoffice: Version: 6.0.7.3
Build ID: 1:6.0.7-0ubuntu0.18.04.10

Libreoffice didn't appear to be using an internal version of python, but rather my generic installation.

@jjchico
Copy link

jjchico commented Dec 7, 2020

I confirm that in Ubuntu 20.04 it works by renaming the extension file to "codehighlighter.oxt" before installing. It works with pygments installed in either way "sudo apt install python3-pygments" or "sudo pip3 install pygments".

@MarkoTF
Copy link

MarkoTF commented Jan 15, 2021

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt

Have a good day!
This works for me, tanks.

@Langlais115
Copy link

On Ubuntu 18.04, I managed to fix the issue by installing LibreOffice with apt-get instead of snap. Not sure what the issue was or if it was even related to that, but it might be worth a try.

snap put you applications in a container and therefore can't access your system library.
That's why.

@Langlais115
Copy link

Renaming the installation file worked for me!

This fix my issue as well.

  1. Removed the extension (Tools > Extension Manager)
  2. Rename the install file to codehighlighter.oxt
  3. Reinstall the extension

@MrPancakes39
Copy link

I had same problem but was able to fix it by:
1- Removing extension.
2- Renaming my file to codehighlighter.oxt.
3- Reinstalling the extension from the new file.
4- Restarting LibreOffice.

@DrakoRod
Copy link

Hi!
First: Thanks for this cool extension!
Second:
Error described here occurs if you download extension many times and install it from the file like codehighlighter-1.oxt or codehighlighter (1).oxt . Note original name is codehighlighter.oxt.
In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with name codehighlighter-1.oxt.
Simply solutions is reinstall plugin from file codehighlighter.oxt
Have a good day!

For me the solving hint. It was not because of downloading it multiple times, but download file had an additional prefix: ea4db15f_codehighlighter.oxt. After renaming it works on my system.

Work for me Thanks

Kubuntu: 20.04
LibreOffice: 6.4.6.2

@OsvaldoSan
Copy link

I had a similar problem and I solved it copying /usr/local/lib/python3.7/dist-packages/pygments/ to /opt/libreoffice6.4/program with
sudo cp -r /usr/local/lib/python3.7/dist-packages/pygments/ /opt/libreoffice6.4/program

@ChunKai-Wang
Copy link

Win10, LibreOffice 7.1.3.2
finally working,
what I have done:
1.PYTHONPATH environment variable
2.Copy pygments folders to LibreOffice installation path
3.Install extension with name codehighlighter.oxt
4.Install extension only for me, not all user. <= After this, I can use this cool extension.

@dwcdev
Copy link

dwcdev commented Jul 6, 2021

Kudos to @yneuma , renaming the extension fixed it for me on my Fedora 32 system. I'd tried manually copying the pygments folder etc, but it turns out the default filename of the package after you download it from the extensions website is the problem.

So get rid of the ea4db15f_ in the package filename...

This fixed my issue. (Ubuntu 20.04)

@AnwarMEQOR
Copy link

For me, the problem occured when I installed the extension from the file named "ea4db15f_codehighlighter.oxt". I changed the name to "codehighlighter.oxt" and reinstalled and now it's working properly. I guess somehow libraOffice cannot find the extension if the name of installation file is different to "codehighlighter.oxt".
Using: Ubuntu 20.04.3 LTS and LibreOffice 6.4.7.2

@Mr-DATA
Copy link

Mr-DATA commented Dec 6, 2021

Solution for windows :

  • install pygments from cmd with this command:
    pip install pygments
  • Copy folders Pygments and Pygments-X.X.X.dist-info from "C:\Users\YourName\AppData\Local\Programs\Python\PythonXXX\Lib\site-packages" to "C:\Program Files\LibreOffice\program"

@GaleasAndres
Copy link

GaleasAndres commented Jul 4, 2022

Alternative:
I tried an alternative and it works perfectly: "Code Highlighter 2".
You can download it here: https://extensions.libreoffice.org/pt-BR/extensions/show/5814

@winnewoerp
Copy link

After experimenting a bit, I discovered that, when installing, the file name had to be named exactly codehighlighter.oxt. When downloaded from https://extensions.libreoffice.org/en/extensions/show/code-highlighter, an additional string is tacked onto the beginning of the text. It doesn't appear necessary to do anything else except install the dependencies with the recommended commands.

System: Ubuntu 18.04.4 LTS Libreoffice: Version: 6.0.7.3 Build ID: 1:6.0.7-0ubuntu0.18.04.10

Libreoffice didn't appear to be using an internal version of python, but rather my generic installation.

That worked in my case. Thank you! (LO 6.4.7.2 on Linux Mint 20.3 Cinnamon)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests