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.