问题描述
我在 Ubuntu 11.10 上使用 PyCharm 2.5,尝试在 Python 3.2.2 上使用 PyGObject 3.0 开发应用程序.我已经安装了 Ubuntu 软件包 python3-gobject,当我运行我的代码时,它完全按预期工作.
I'm using PyCharm 2.5 on Ubuntu 11.10, trying to develop an application using PyGObject 3.0 on Python 3.2.2. I've installed the Ubuntu package python3-gobject, and when I run my code, it works exactly as expected.
然而,PyCharm 似乎无法找到任何 PyGObject 模块.当我在导入语句中将鼠标悬停在 Gtk 上时,它显示 Unresolved refrence: 'Gtk'
,当然没有自动完成工作.
However, PyCharm can not seem to find any of the PyGObject modules. It says Unresolved refrence: 'Gtk'
when I hover over Gtk in my import statement, and of course none of the auto-completion works.
这是我的代码:
#!/usr/bin/env python3
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
我什至尝试制作一个 python 虚拟环境,然后从源代码安装 PyGObject,然后甚至尝试从 site-packages/gi/overrides
中的所有 .py 文件制作符号链接到site-packages/gi/repository
,一切都没有运气.
I've even tried making a python virtual environment and then installing PyGObject from source into it, and then even tried making symlinks from all the .py files in site-packages/gi/overrides
to site-packages/gi/repository
, all with no luck.
任何建议将不胜感激!
推荐答案
在 Gtk+ 3 中,Python 绑定到二进制模块是使用 *.typelib
数据库动态生成的.用于访问所有模块的动态导入器位于 gi.repository
中.PyCharm 无法使用其代码洞察来检测这些模块,因为它们需要特殊处理.
In Gtk+ 3 Python bindings to binary modules are generated dynamically using *.typelib
databases. The dynamic importer for accessing all the modules is located in gi.repository
. PyCharm cannot detect these modules using its code insight, because they require special handling.
我已针对此问题提交了功能请求:PY-6932.请随意投票.
I've filed a feature request for this issue: PY-6932. Feel free to vote for it.
这篇关于PyCharm 无法解析 PyGObject 3.0,但代码运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!