PyCharm 3.1 hangs forever during indexing and unusable(PyCharm 3.1 在索引期间永远挂起并且无法使用)
问题描述
更新到 3.1 后,PyCharm 在索引"包期间永远挂起(在 OSX 10.9.1、Python 2.7.5 上).
After updating to 3.1, PyCharm hangs forever (on OSX 10.9.1, Python 2.7.5) during the "indexing" of packages.
对我来说,这发生在索引 scipy
(0.13.3) 时.如果我卸载 scipy
,索引似乎已完成,但随后又挂在pythonstubs"上.UI 变得无响应,CPU 使用率达到最大值,我无法执行任何操作,不得不强制退出应用程序.
For me this occurs while indexing scipy
(0.13.3). If I unistall scipy
, indexing appears to complete, but then hangs again on "pythonstubs". The UI becomes unresponsive, CPU use is maxed, and I'm unable to do anything and have to force-quit the app.
如果我重新安装 scipy,PyCharm 会在 scipy 扫描的同一位置再次挂起(请参阅对话框的屏幕截图):
If I reinstall scipy, PyCharm hangs again at the same spot in the scipy scan (see screen capture of dialog):
FWIW,我可以毫无问题地从系统命令行运行 Python 脚本(包括一些使用 scipy
和许多其他最近更新或安装的软件包),因此 Python 安装是正确的.
FWIW, I can run Python scripts from the system command line (including some that use scipy
and many other packages recently updated or installed) without issue, so the Python installation is sound.
有没有人遇到过类似的问题或找到解决方法?
Has anyone had a similar problem or found a way around this one?
推荐答案
问题在于任何可能已定义用于识别 TODO 项的正则表达式匹配.PyCharm 用于匹配这些项目的 Java 标准正则表达式库使用指数复杂度的算法来搜索 '*.a'
和类似模式.
The problem lies with any regular expression matches that may have been defined to identify TODO items. The Java standard regular expression library used by PyCharm to match these items uses an algorithm of exponential complexity to search for '*.a'
and similar patterns.
理论上,可以非常快速地匹配任何正则表达式(存在线性算法),> 但是许多正则表达式库的开发人员根本不费心去实现它.
Theoretically, it is possible to match any regexp very fast (a linear algorithm exists), > but many developers of regexp libs simply don't bother implementing it.
Python re 模块也存在同样的问题:
The same problem exists for the Python re module:
>>> from timeit import timeit
>>> timeit("import re; list(re.finditer('.*a', 'foo' * 10000))", number=1)
0.6927990913391113
>>> timeit("import re; list(re.finditer('.*a', 'foo' * 50000))", number=1)
17.076900005340576
一般来说,如果索引需要很长时间或挂起,请查看 TODO 项中的正则表达式,看看是否可以缩小匹配范围以提高性能.
In general, if indexing is taking a long time, or hanging, look to the RegEx in your TODO items and see if you can narrow the scope of matches in order to improve performance.
这篇关于PyCharm 3.1 在索引期间永远挂起并且无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PyCharm 3.1 在索引期间永远挂起并且无法使用
基础教程推荐
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01