我现在所做的是开发一个
GTK+
应用程序,需要从
这里 下载并安装
Anaconda3
,然后使用以下命令创建一个新的虚拟环境:
conda create --name xld-attribute-value-adder python=3.4 pip setuptools pygobject
我添加了pip和setuptools,因为virtualenv在创建虚拟环境时会添加它们。我知道可以使用pip来安装软件包,但setuptools的名称意味着它可以用于类似的用途。
然后Anaconda告诉我找不到PyGObject,并且我可以使用binstar进行搜索(太好了,又要记住另一个工具!)如下:
binstar search -t conda pygobject
然而,这会导致多个搜索结果:
Name | Version | Package Types | Platforms
------------------------- | ------ | --------------- | ---------------
???/pygobject3 | 3.12.0 | conda | linux-64
: None
KristanArmstrong/pygobject | 3.14.0 | conda | win-64
: PyGObject is a Python extension module that gives clean and consistent access to the entire GNOME software platform through the use of GObject Introspection.
fallen/pygobject | 3.14.0 | conda | linux-64, linux-32
: PyGObject is a Python extension module that gives clean and consistent access to the entire GNOME software platform through the use of GObject Introspection.
jeanconn/pygobject | | conda | linux-64
: None
pkgw/pygobject3 | 3.12.0 | conda | linux-64
: None
ska/pygobject | 2.20.0 | conda | linux-64
: Pipeline running tools
vgauthier/pygobject | 3.10.0 | conda | osx-64
: Python Bindings for GLib/GObject/GIO/GTK+
那么我应该安装哪一个呢?当然是最新和最稳定的...其中一些不符合要求,因为它们不适用于我的
linux-64
系统。我想进行搜索,只显示适用于我的系统的软件包,所以我找到了一些帖子告诉我,在
Anaconda网站上输入以下内容即可进行此类搜索:
access:public platform:linux-64 pygobject
现在我只看到4个结果,仍然不知道哪一个是最新的,或者应该使用哪一个。Anaconda网站也没有告诉我这些存储库何时被更新。因此,我认为版本号最高的那个应该是最新的。事实上,我发现了一个网站,它声称PyGObject 3.14
版本是2014年9月22日
发布的,或者至少该网站上的帖子是从那个日期。
我创建了虚拟环境,没有使用pygobject参数:
conda create --name xld-attribute-value-adder python=3.4 pip setuptools
然后激活它:
source activate xld-attribute-value-adder
然后使用以下命令安装了
PyGObject
:
conda install -c https://conda.anaconda.org/fallen pygobject
接着,我在我的IDE PyCharm中更改了该项目的Project Interpreter
(是的,我目前正在使用PyCharm进行此项目),将其更改为新创建的虚拟环境的Python 3.4
二进制文件:
(Project Directory)/bin/python3.4
接下来我打开一个Python文件,其中包含以下代码:
from gi.repository import Gtk
PyCharm目前无法找到Gtk或存在其他问题,因此我需要点击下划线红色的
Gtk
,然后在上面按
Alt+Enter
,选择创建二进制存根。
经过这些步骤,它最终工作了:)