Windows 7上的Pycharm 3.4.1无法为PyQt v4.11.2生成框架 [英] Pycharm 3.4.1 on Windows 7 cannot generate skeletons for PyQt v4.11.2

查看:63
本文介绍了Windows 7上的Pycharm 3.4.1无法为PyQt v4.11.2生成框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题
在Windows 7 64位系统上的PyCharm 3.4.1中,为PyQt库(v4.11.2,安装了二进制"PyQt4-4.11.2-gpl-Py3.4-Qt4.8.6-x64.exe"安装)的框架生成失败,从库中导入类时会抛出未解决的引用,从而禁用任何代码完成功能.我在运行完全相同版本的Ubuntu的计算机上进行了项目设置,一切正常.

安装信息
安装的Python版本是3.4.0(并且也尝试过3.4.1,因为我认为PyQt库专门用于3.4.0,而不是3.4.1,但是发出的问题相同. )PyCharm是在Python之前安装的,尽管我怀疑这样做有什么不同.当然,PyQt库是在Python之后安装的,它位于我的python34文件夹中Lib文件夹的站点包中,该文件夹位于C驱动器的根目录下.如果有帮助,我还有一个分区(D驱动器).

相关信息
经过一些研究,我发现在PyCharm中使用不同库的骨架生成存在很多问题,其中许多相当古老(〜2011年),并且此后已被修复".没有出现适合我的情况的答案,包括使缓存无效/重新启动PyCharm,重新加载PyCharm解释器中的路径列表,创建VirtualEnv解释器,在控制台中运行generator3.py脚本.

关于那个generator3. py脚本,它是负责创建框架的脚本,奇怪的是,当我从控制台运行它时,python.exe崩溃了,而IMO可能是问题的根源.我没有研究该文件中包含的代码,但是无论如何,我认为Python不应崩溃,但是如果出现问题,请报告某种错误.

相关问题
https://stackoverflow. com/questions/25782513/no-autocomplete-for-pyqt4-in-pycharm?rq = 1
(解决方法是先安装PyCharm,这已经属于我了)

解决方法
由于我在Ubuntu机器上具有与Qt完全相同版本的框架,因此我只是将文件复制到包含框架的文件夹中,该文件夹的潜在随机数位于〜.PyCharm30 \ system \ python_stubs(我认为有每个口译员一个).但是问题是,PyCharm会在每次启动时尝试生成它,并覆盖我们手动复制的文件,因此为了防止它发生(因为我们无法禁用自动生成,烦人的事情……)我做了一个备份generator3.py文件,并用清空所有方法的版本替换它,并用pass或return True替换,这样PyCharm会认为它已经成功生成了文件,但是只使用了我们复制的文件. /p>

当然,这很脏,需要您已经拥有文件.我会好心的,如果这个问题毕竟是一个错误,则可以使用我使用的框架文件和经过修改的生成器python文件,使其至少在修复时起作用.

下载替代方法: https://app.box.com/s/uulw818dfkzjdpyyty2y

解决方案

不是答案,但可能对其他人有用: https://youtrack.jetbrains.com/issue/PY-14235 ,以获取有关其他版本PyQt的工作框架的详细信息.

ISSUE
In PyCharm 3.4.1 on Windows 7 64bits, the skeleton generation for the PyQt library (v4.11.2, installed with the binary "PyQt4-4.11.2-gpl-Py3.4-Qt4.8.6-x64.exe") fails, which throws unresolved references when importing classes from the library, disabling any code completion feature. I had the project setup on a computer running Ubuntu with the exact same version, and everything was working fine.

INSTALLATION INFORMATION
The version of Python installed is 3.4.0 (and was tried with 3.4.1 as well, as I thought it might be that the PyQt library was working specifically with 3.4.0, not 3.4.1, but the issue it the same.) PyCharm was installed prior to Python, even though I doubt it makes any difference. Of course the PyQt library was installed after Python, and it is located in the site-packages of the Lib folder in my python34 folder, which is at the root of my C drive. If that's of any help, I have one other partition (D drive).

RELATED INFORMATION
After some research, I found that there were quite a bit of problems with skeleton generation with different libraries in PyCharm, many rather old (~2011) and which have been "fixed" since. No answer came up that worked in my case, including invalidate cache/restart PyCharm, reloading list of paths in the PyCharm interpreter, creating a VirtualEnv interpreter, running the generator3.py script in console.

Concerning that generator3.py script, it is the one responsible for creating the skeletons, and the odd thing is that when I run it in from console, python.exe crashes, which IMO is probably the root of the problem. I have not investigated the code contained in that file, but anyways I think that Python shouldn't crash, but report an error of some kind if there were a problem with it.

Related issues
https://stackoverflow.com/questions/25782513/no-autocomplete-for-pyqt4-in-pycharm?rq=1
(Resolved by installing PyCharm first, which is already my case)

Workaround
Since I had the skeletons for the exact same version of Qt on my Ubuntu machine, I just copied the files to the folder holding the skeletons, a folder with a potentially random number located in ~.PyCharm30\system\python_stubs (I think there is one for each interpreter). The problem though is that PyCharm will try to generate it upon each startup, and override the file we manually copy, so to prevent it from doing so (since we can't disable automatic generation, annoying...) I made a backup of the generator3.py file and replaced it with a version with all the methods emptied and replaced with either pass or return True, such that PyCharm will think it has succeeded in generating the files, but it just takes the one we've copied.

Of course, this is pretty dirty and requires you to have the files already. I'll be kind and if that issue is after all a bug, you can use the skeleton files I used and the modified generator python file to make it work at least meanwhile they work on a fix.

Download the workaround: https://app.box.com/s/uulw818dfkzjdpyyty2y

解决方案

Not an answer but might be useful to others: https://youtrack.jetbrains.com/issue/PY-14235, for details on getting a working set of skeletons for other versions of PyQt.

这篇关于Windows 7上的Pycharm 3.4.1无法为PyQt v4.11.2生成框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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