PyCharm无法解析PyGObject 3.0,但代码运行正常 [英] PyCharm can not resolve PyGObject 3.0, but code runs fine

查看:194
本文介绍了PyCharm无法解析PyGObject 3.0,但代码运行正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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模块.当我在import语句中将鼠标悬停在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 +中,使用*.typelib数据库动态生成到二进制模块的3个Python绑定.用于访问所有模块的动态导入器位于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,但代码运行正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆