使用 pydev 和 .pth 文件导入

发布于 2025-01-03 06:49:54 字数 680 浏览 2 评论 0原文

相关于: PyDev 和 Eclipse 未解决的导入问题

最近,我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在风中等你 2025-01-10 06:49:54

尝试通过转到“窗口”->“重新配置解释器”。首选项-> PyDev-> Interpreter-Python 并再次删除并添加 Python 解释器。

Try reconfiguring the Interpreter by going to Window -> Preferences -> PyDev -> Interpreter-Python and removing and adding the Python interpreters again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文