如何从现有代码创建 PyDev 项目?

发布于 2024-12-04 17:41:57 字数 854 浏览 0 评论 0 原文

我创建了一个 python 项目,开始在 TextPad 和命令提示符中进行开发。

http://pydev.org/manual_101_project_conf.html

本文档简要提到了使用现有代码创建项目,但是我无法理解它......

它说: 创建项目,就像它是一个新项目一样,但保留创建默认“src”文件夹选项未选中并将位置指向源(或更高级别)——下一个教程页面将解释配置 PYTHONPATH 的步骤(应该在以这种方式创建项目后完成)。

这很有意义,所以我创建了一个新项目并已选择 不要配置 PYTHONPATH(稍后手动完成)

一切都很好,有足够的意义。因此,您可以导航到下一页,据说它说明了如何配置 PYTHONPATH,这应该以某种方式使该项目包含 src 文件???...

http://pydev.org/manual_101_project_conf2.html

据说此链接包含从现有代码创建项目的信息。它说明了如何创建源文件,很简单...所以我将现有代码复制到源文件夹中?

好吧,这工作得很好,我现在可以在 src 文件夹中运行我的模块,但它提到我应该将其添加到 PYTHONPATH 中。如果我的文件按预期运行,为什么我需要这样做?这样做有什么目的?

在这个过程中我还遗漏了什么吗?到目前为止,文档让我感到困惑......寻找基础知识,任何信息都会很棒

I have created a python project which I began development in TextPad and Command Prompt.

http://pydev.org/manual_101_project_conf.html

This documentation briefly mentions creating a project with existing code, but I can't make sense of it...

Is says: Create the project as if it was a new project, but leave the create default 'src' folder option unchecked and point the location to the location of the sources (or a level above) -- the next tutorial page will explain the steps to configure the PYTHONPATH (which should be done after creating the project this way).

which makes enough sense, so I created a new project and selected
Don't configure PYTHONPATH (to be done manually later on)

All fine, makes enough sense. So you can navigate to the next page where supposedly it says how to configure the PYTHONPATH, which should somehow make this project contain the src files???...

http://pydev.org/manual_101_project_conf2.html

Supposedly this link contains information to create the project from the existing code. It says how to create a source file, easy enough... So I take me existing code and copy it into the source folder?

Well this works well enough, I can now run my modules inside the src folder, but it mentions I should add it to the PYTHONPATH. If my files are running as expected why do I need to do this? What purpose does that serve?

Is there anything else I'm missing in this process? The documentation just confuses me so far... Looking for the basics, any information would be awesome

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

清风夜微凉 2024-12-11 17:41:57

根据我的经验,在 PyDev 中配置 PYTHONPATH 有两个主要兴趣:

  • 一个明显的兴趣是,如果您有多个包含模块的文件夹,它允许在文件夹 a 中运行的代码导入文件夹 b 中的模块em>
  • 另一个问题是,PyDev 似乎依赖于此来启用代码完成的某些部分,以及代码分析;对于不属于 PYTHONPATH 的 Python 源,不会启用最后一个有用的功能。

From my experience, configuring the PYTHONPATH in PyDev has two main interests :

  • an obvious one if you have multiple folders containing modules, it allows code running in folder a to import modules in folder b
  • another one, is that PyDev seems to rely on this to enable some parts of code completion, and also code analysis ; this last useful feature is not enabled for python sources that are not part of the PYTHONPATH.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文