libreoffice-code-highlighter
libreoffice-code-highlighter copied to clipboard
A Scripting Framework error occurred while executing the Python script
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 ]
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]
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
Same here: Ubuntu 18.10 Libreoffice 6.1.3
Please check the latest release v1.5.
Same here (with v1.5) Linux Mint 18.1 LO: 6.1.4.2
@JLuisGT could you please give some more information?
- Does it occur only in LO Impress or in Writer too?
- 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?
- Could you please share the screenshot of the error message?
Hi @slgobinath It's very attentive of you to answer this fast!
-
It happens in both Impress and Writer.
-
It happens both, selecting the code AND selecting a text box with the code inside.
-
For sure!
Hi, May I know how you installed the extension? Did you install it only for the current user or for all users?
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.
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/
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.
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.
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.
[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
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!
I also have the same error:
on Windows 10, x64, libreoffice 6.1.5.2 and I install the extension using codehighlighter.oxt file.
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.
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 had the same issue but it was solved once I installed python3-pygments, python3-pip, etc. using sudo apt install package
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
I also have the same error:
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
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)
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.
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 :)
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
orcodehighlighter (1).oxt
. Note original name iscodehighlighter.oxt
. In the Framework code occurs search by extension name, and in first case name are wrong. Framework cannot find extension with namecodehighlighter-1.oxt
. Simply solutions is reinstall plugin from filecodehighlighter.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.
Maybe this error popup should display a link to this ticket :)
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...
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:
- Renamed the file in my /tmp/mozilla_username0/ folder to remove the prefix.
- Removed the extension from LibreOffice Writer.
- Double-clicked on the extension in pcmanfm.
- Clicked "install".
- Clicked "accept".
- Restarted LibreOffice Writer.
And it worked, all of a sudden. Nothing else in my system changed.
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 ;)
Renaming the installation file worked for me!