Pycharm(Python IDE)不会自动完成Django模块 [英] Pycharm (Python IDE) doesn't auto complete Django modules
问题描述
我的Python IDE(pycharm)已经停止自动完成我的模块(建议)。我尝试导入所有django模块后,得到未解析的引用:
从django
- 尽管如此我添加一个'点'它失败,所以从$ d code>从django.db导入模型给我未解决的错误...
我发现我所有的 __ init __。py
文件(到处都是)不再标有python图标,现在是记事本图标。同时在我的解释器中打开init文件会给出非颜色标记的文本(没有语法突出显示)。所以我认为Python不能识别这些文件。
我的python解释器是python 2.6.1与Django 1.2.4,我的django安装在:
/Lib/python/2.6/site-packages
(完整的目录,而不是蛋)
当我展开来自IDE中的外部库我看到所有.py文件的颜色标记EXCEPT __ init __。py
文件。因此,这个问题在哪里生活。
(我在google上发现类似的问题,但没有答案...)
我有完全相同的问题,找不到确定的答案。刚刚使缓存缓存无效。问题在于,在某些时候, __ init __。py
文件被注册为文本文件,并搞砸了索引。我制定了这个修复程序:
- 首选项>文件类型>文本文件。
- 删除<$从注册模式列表中的c $ c> __ init __。py
- 等待您的索引重新构建。
- (如果仍然不起作用)File> Invalidate caches&重新启动。
My Python IDE (pycharm) has stopped auto completing my modules (suggestions). I get unresolved references after every django module I try to import so:
from django
- works, however soon as I add a 'dot' it fails so from django.db import models
gives me unresolved errors...
The ackward thing is after compiling references DO work.
I discovered that all my __init__.py
files (everywhere) no longer are marked with python icon and are now notepad icons. Also opening init files in my interpreter gives non-color marked up text (no syntax highlighting). So I think Python doens't recognizes these files.
My python interpreter is python 2.6.1 with Django 1.2.4 and my django is installed under:
/Lib/python/2.6/site-packages
(full directories, not egg)
When I unfold sitepackages from external libraries within the IDE I do see colored mark up for all .py files EXCEPT __init__.py
files. Hence thats where the issue lives.
(I have found posts on google for similar problems but no answers...)
I had exactly the same issue and couldn't find a definitive answer. Just invalidating caches didn't work for me. The problem lies in the fact that, at some point, __init__.py
files got registered as text files and messed up the indexing. I worked out this fix:
- Preferences > File Types > Text Files.
- Remove
__init__.py
from the list of registered patterns. Apply. - Wait for your indexes to re-build.
- (If it's still not working) File > Invalidate caches & restart.
这篇关于Pycharm(Python IDE)不会自动完成Django模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!