使用pydev和.pth文件导入 [英] Importing using pydev and .pth files
问题描述
最近我把我的django包转移到django_trunk,所以我可以在其他地方有一个开发版本。我没有问题导入django,runserver或其中任何一个。
Recently I moved my django package to django_trunk so I can have a development version elsewhere. I have no issue importing django, runserver, or any of that.
我的问题(烦恼?)是所有的进口都出现了强调的红色表示错误
My issue (annoyance?) is that all of the imports are coming up as underscored red indicating an error.
Pydev清楚地知道进口,但无论什么原因仍然导入为红色。
Pydev clearly knows of the imports, but for whatever reason it still imports as red.
已经注意到这个与其他几个包,它们使用.pth文件而不是直接导入。过去我只是忽略了红色,但是django是屏幕的一半,我正在失去重要的信息。
I've noticed this with a few other packages, which use a .pth file instead of a direct import. In the past I've just ignored the red, but with django it's half my screen and I'm loosing critical information.
演示:
import django #note that django is underscored as red
import sys
print django
print sys.path
模块'django' \django_trunk\django__init __。pyc'
[...,'C:\Python27\Lib\site-packages\django_trunk',...]
module 'django' from 'C:\Python27\Lib\site-packages\django_trunk\django__init__.pyc' [...,'C:\Python27\Lib\site-packages\django_trunk', ...]
推荐答案
尝试通过转到Window - > Preferences - > PyDev - > Interpreter-Python重新配置Interpreter,然后再次删除并添加Python解释器。
Try reconfiguring the Interpreter by going to Window -> Preferences -> PyDev -> Interpreter-Python and removing and adding the Python interpreters again.
这篇关于使用pydev和.pth文件导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!