gedit plugin error - plugin loader 'python3' was not found
Asked Answered
S

4

8

I tried to add some plugins in gedit 3.10.4 on ubuntu 14.04LTS and some errors occured when I try to activate those plugins in gedit:

(gedit:20686): libpeas-WARNING **: Error initializing Python Plugin Loader: PyGObject initialization failed ImportError: could not import gobject (error was: ImportError("No module named 'gi'",))

(gedit:20686): libpeas-WARNING **: Please check the installation of all the Python related packages required by libpeas and try again

(gedit:20686): libpeas-WARNING **: Loader 'python3' is not a valid PeasPluginLoader instance

(gedit:20686): libpeas-WARNING **: Could not find loader 'python3' for plugin 'bracketcompletion'

And I see, on ged

plugin loader 'python3' was not found

Does anyone have an idea from where the problem could come?

Silicone answered 10/3, 2015 at 13:4 Comment(0)
G
4

I had this very same error with a different plugin (reST). The problem the error was caused by was that I had run it from the command line when a virtual environment was active. For this reason Python3 did not use (and find) the system libraries.

Solution: I ran gedit just normally from the GUI (or after deactivating the virtualenv in the Terminal), and the editor and the plugin just loaded fine. Double-check if you have a similar cause.

Otherwise you probably really have to check on what the error message says: Whether all "related packages required by libpeas" are installed. See details of package libpeas-1.0-0 for Trusty.

Geneticist answered 6/6, 2016 at 9:24 Comment(0)
C
3

To add to @Railslide 's answer:

  1. In your /usr/lib/gedit/plugin search for your plugin file (e.g. bracketcompletion.plugin) and change Loader=python3 to Loader=python

  2. If this still returns an error - likely because it doesn't match python3 syntax: Use the command 2to3 as follows:

    cd python_directory/
    sudo 2to3 -f all -w *
    

e.g. for gedit-latex-plugin...

cd /usr/lib/gedit/plugins/
sudo sed -i 's/python/python3/g' latex.plugin # only if you haven't already replaced python->python3
cd latex/
sudo 2to3 -f all -w *

Then this fixes the plug-in by replacing python2.x code with python3 code

Related

Comedic answered 6/7, 2016 at 23:19 Comment(3)
how to undo this command sudo 2to3 -f all -w *? because after this other applications such as anaconda are not working.Woof
Could anyone help me with this pleaseWoof
I can only assume you didn't do it within the latex/ directory and instead did it on maybe lib/. If you did do that, it is an exceptional blunder and you will need to reinstall all the broken libs or restore from a backupComedic
G
0

It's a gedit bug, see https://bugs.launchpad.net/ubuntu/+source/gedit/+bug/859089

As a workaround, in your /usr/lib/gedit/plugin search for your plugin file (e.g. bracketcompletion.plugin) and change Loader=python3 to Loader=python

Unfortunately, this workaround doesn't work for all the plugins.

Giselagiselbert answered 10/3, 2015 at 13:19 Comment(1)
Thanks for your answer but it is not changing anything... Now the error is "pluging loader 'python' was not found"Silicone
M
0

I've encountered essentially the same problem today, though with the code-comment plugin. In my case, the issue only showed up when gedit was executed from the command line, similarly to @Peterino (though no virtual environment had actually been explicitly set up). Everything was fine otherwise.

The reason why this happened seems to be linked to the fact that I have set up my $PATH in .bashrc in such a way that python3 corresponds to a local anaconda/miniconda installation. An unwanted side effect is that, when launched from the terminal, gedit then actually picks the local miniconda install instead of /usr/bin/python3.X. (Checked by temporarily moving the miniconda folder elsewhere or login-in as another user).

Possible fixes

(Though I'm still not completely satisfied with either of them).

Putting this in .bashrc works:

export CONDAPATH=$HOME/miniconda3/bin
export PATH="$CONDAPATH:$PATH"
# ^ put these two lines instead of the original miniconda export.

# __ : naming convention for private functions
__geditfix() {
    export PATH=$(echo $PATH | sed -E "s|:$CONDAPATH\|$CONDAPATH:||g"); # remove conda from the PATH environment variable, using RegEx
    gedit "$@"; # call gedit, giving it all arguments
    export PATH="$CONDAPATH:$PATH"; # add conda to the PATH environment variable
} # Using a function rather than an alias, so that the filename is given to gedit, as it should and not to setconda().

alias gedit='__geditfix' # So that we can run our fix simply via: gedit <arguments>.

What this ^ does is to create an alias for gedit, using a function which actually

  • 1) removes ~/miniconda3/bin from $PATH,
  • 2) runs gedit (/usr/bin/gedit), giving it all arguments,
  • 3) puts back ~/miniconda3/bin in our $PATH.

With these few lines in .bashrc, one can simply call gedit <arguments>

  • the plugins work since gedit will pick python from /usr/bin/,
  • python, jupyter-notebook, conda, and the like from miniconda can still be directly accessed without problem

btw, this helped: https://mcmap.net/q/98707/-environment-variable-substitution-in-sed (environment variables substitution in sed)

Alternative solution: install this v:

conda install -c conda-forge pygobject

As could be guessed from the terminal outputs it was missing when using the miniconda python3 install.

Mayolamayon answered 4/12, 2018 at 18:2 Comment(1)
As of today, my favourite solution is to now instead use a virtual environment that I only activate when I explicitly want to work with python or jupyter in that specific terminal. I chose venv, see docs.python.org/3/library/… You can create a new environment (only needs to be done once) e.g. via: python3 -m venv /yourpath/to/new/virtual/environment Then to activate it, simply do: source /yourpath/to/new/virtual/environment/bin/activate And to deactivate it, simply type deactivate.Mayolamayon

© 2022 - 2024 — McMap. All rights reserved.