gedit插件错误 - 找不到插件加载器'python3'

时间:2015-03-10 13:04:01

标签: python gedit gedit-plugin

我试图在ubuntu 14.04LTS上的gedit 3.10.4中添加一些插件,当我尝试在gedit中激活这些插件时出现了一些错误:

  

(gedit:20686):libpeas-WARNING **:初始化Python插件加载器时出错:PyGObject初始化失败   ImportError:无法导入gobject(错误是:ImportError("没有名为' gi'",)的模块)

     

(gedit:20686):libpeas-WARNING **:请检查libpeas所需的所有Python相关软件包的安装,然后重试

     

(gedit:20686):libpeas-WARNING **:Loader' python3'不是有效的PeasPluginLoader实例

     

(gedit:20686):libpeas-WARNING **:找不到加载程序' python3' for plugin' bracketcompletion'

我在ged上看到了

  

插件加载器' python3'没找到

有没有人知道问题可能来自哪里?

4 个答案:

答案 0 :(得分:2)

我使用不同的插件(reST)时遇到了同样的错误。错误导致的问题是,当 virtual environment 处于活动状态时,我从命令行运行了该错误。出于这个原因,Python3没有使用(并找到)系统库。

解决方案:我正常地从GUI运行gedit(或者在终端中停用virtualenv之后),编辑器和插件刚好加载。仔细检查您是否有类似的原因。

否则你可能真的要检查错误信息的内容:是否所有" 相关的包都是libpeas "已安装。查看Trusty的包libpeas-1.0-0的详细信息。

答案 1 :(得分:2)

添加到@Railslide的答案:

  1. /usr/lib/gedit/plugin搜索您的插件文件(例如bracketcompletion.plugin)并将Loader=python3更改为Loader=python

  2. 如果仍然返回错误 - 可能是因为它与python3语法不匹配:使用命令2to3,如下所示:

    cd python_directory/
    sudo 2to3 -f all -w *
    
  3. e.g。 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 *
    

    然后通过将python2.x代码替换为python3代码来修复插件

    相关

答案 2 :(得分:0)

这是一个gedit错误,请参阅https://bugs.launchpad.net/ubuntu/+source/gedit/+bug/859089

作为解决方法,在/usr/lib/gedit/plugin搜索您的插件文件(例如bracketcompletion.plugin)并将Loader=python3更改为Loader=python

不幸的是,这种解决方法doesn't work for all the plugins

答案 3 :(得分:0)

尽管使用代码注释插件,但今天 我基本上遇到了相同的问题。就我而言,该问题仅在从命令行执行gedit时出现,类似于@Peterino(尽管实际上未明确设置任何虚拟环境)。否则一切都很好。

发生这种情况的原因似乎与以下事实有关:我在$PATH中设置了.bashrc,使得python3对应于本地 anaconda / miniconda 安装。有害的副作用是,gedit从终端启动时实际上会选择本地的miniconda安装而不是/usr/bin/python3.X。 (通过将miniconda文件夹临时移动到其他位置或以其他用户身份登录进行检查。)

可能的解决方法

(尽管我对其中任何一个都不完全满意)。

将其放入.bashrc可以正常工作:

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>.

此^的作用是使用实际上是

的函数为gedit创建别名
  • 1)从~/miniconda3/bin中删除$PATH
  • 2)运行gedit(/usr/bin/gedit),并为其提供所有参数,
  • 3)将~/miniconda3/bin放回我们的$PATH中。

有了.bashrc中的这几行内容,您可以简单地调用gedit <arguments>

  • 插件可以正常工作,因为gedit将从python中选择/usr/bin/
  • 仍然可以直接访问miniconda中的
  • pythonjupyter-notebookconda等类似内容

顺便说一句,这有助于:https://stackoverflow.com/a/23134318/452522(sed中的环境变量替换)

替代解决方案:安装此v:

conda install -c conda-forge pygobject

从终端输出中可以猜到,使用miniconda python3安装时缺少它。