使用 pydev 和 .pth 文件导入
最近,我将 django 包移至django_trunk 这样我就可以在其他地方拥有开发版本。我导入 django、runserver 或其中任何一个都没有问题。
我的问题(烦恼?)是所有导入都显示为红色下划线,表示有错误。
Pydev 清楚地知道导入,但无论出于何种原因,它仍然以红色导入。
我在其他一些软件包中注意到了这一点,它们使用 .pth 文件而不是直接导入。过去我只是忽略了红色,但对于 django,它占据了我的一半屏幕,我正在丢失关键信息。
演示:
import django #note that django is underscored as red
import sys
print django
print sys.path
来自 'C:\Python27\Lib\site-packages\django_trunk\django__init__.pyc' 的模块 'django' [...,'C:\Python27\Lib\site-packages\django_trunk', ...]
related to:
Unresolved Import Issues with PyDev and Eclipse
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 clearly knows of the imports, but for whatever reason it still imports as red.
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.
To demonstrate:
import django #note that django is underscored as red
import sys
print django
print sys.path
module 'django' from 'C:\Python27\Lib\site-packages\django_trunk\django__init__.pyc'
[...,'C:\Python27\Lib\site-packages\django_trunk', ...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试通过转到“窗口”->“重新配置解释器”。首选项-> PyDev-> Interpreter-Python 并再次删除并添加 Python 解释器。
Try reconfiguring the Interpreter by going to Window -> Preferences -> PyDev -> Interpreter-Python and removing and adding the Python interpreters again.