自定义模块的代码完成不适用于PyDev [英] Code completion for custom modules not working with PyDev

查看:127
本文介绍了自定义模块的代码完成不适用于PyDev的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我制作一个名为mylib.py的模块。在日食中我键入

  import mylib 

然后我键入 mylib。并点击CTRL + SPACE。这应该建议mylib中的函数/变量,但它不做任何事情。如果我执行类似 import os 并键入 os。,建议立即弹出,所以我知道代码完成工作一般,只是不是为我的模块。任何原因为什么?

解决方案

为了完成自定义模块,PyDev必须对其进行索引(如果可能),并且内省类,函数,变量和导入。为了做到这一点,你应该把你的模块添加到eclipse的PYTHONPATH中,然后重新编译你的静态文件(在PyDev中定义的)。



大部分时间是由IDE,但它不能很好地工作(至少不完美)。



我真的建议你不要依靠100%的IDE完成。


Let's say I make a module called mylib.py. In eclipse I type

import mylib

Then I type mylib. and hit CTRL+SPACE. This should suggest functions/variables in mylib, but it doesn't do anything. If I do something like import os and type os., suggestions immediately pop up, so I know code completion works in general, just not for my modules. Any reason why?

解决方案

In order to get completion for custom modules, PyDev has to index it (if possible) and introspect the classes, functions, variables and imports defined there. To do so, you should add your module to the eclipse's PYTHONPATH and then reindex your venv (the one defined in PyDev).

Most of the times this is done automatically by the IDE but it doesn't work quite well (at least it is not perfect).

I really suggest you not to rely at 100% on the IDE completion.

这篇关于自定义模块的代码完成不适用于PyDev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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