Eclipse:使用 PyDev 连接到自定义 python 解释器

发布于 2024-12-10 17:01:57 字数 320 浏览 0 评论 0原文

我喜欢 Eclipse 和 PyDev,因为它总有我需要的功能。这次我想将 PyDev 连接到已经运行的解释器。我的解释器嵌入在我的游戏应用程序中,这就是原因。如果这样更容易的话,我还可以从 Eclipse 启动游戏应用程序。

但是,我尝试将我的游戏 .exe 添加到 PyDev 的解释器配置中,但它无法启动,因为 .exe 需要位于 .exe 文件夹中的一些 .cfg 文件。 Ecplise 似乎不在其环境中执行 .exe 文件。我怎样才能做到呢?

这一切的主要原因是我希望能够对在我的应用程序中创建的 python 对象进行代码补全,并让 Eclipse 了解它们。类似于远程变量调试。

I love Eclipse and PyDev because it always has the features I need. This time I'd like to connect PyDev to my interpreter that is already running. My interpreter is embedded in my game application, that's why. If it would make it easier, I can also start the game application from Eclipse.

However, I've tried to add my game .exe in the interpreter configuration in PyDev but it cannot be started because the .exe need some .cfg files that are located in the .exe's folder. Ecplise seems to not execute the .exe file in its environment. How could I do it?

The main reason for all this is that I want to be able have code completion for python objects that are created inside my application and let Eclipse know about them. Similar to remote variable debugging.

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

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

发布评论

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

评论(3

时间你老了 2024-12-17 17:01:57

我不是 100% 确定我是否理解你的核心问题,但这应该回答我认为你想知道的事情:

你不会将编译的游戏可执行文件添加为解释器,因为它不是 python 解释器。 Eclipse 需要一个python 解释器。

如果您想通过(自定义)安装 python 在自定义环境/PYTHONPATH 中运行代码,请转至 Window ->首选项-> PyDev->解释器 - Python。在这里,您可以将 Python 的自定义安装添加为预设,并选择要包含在该解释器预设的 PYTHONPATH 中的环境路径(请确保您不 包含项目本身的源路径,Eclipse 将在您运行项目时添加它们)。

完成后,转到您的项目首选项并从列表中选择新创建的解释器预设(PyDev - 解释器/语法)。

只要您使用 PyDev 编辑器并正确设置 PYTHONPATH 环境,您就可以获得代码补全。

希望有帮助。

I'm not 100% sure if I understand your core question but this should answer what I think you want to know:

You would not add your compiled game executable as an interpreter as it wouldn't be a python interpreter. Eclipse asks for a python interpreter.

If you want to run your code in a custom environment/PYTHONPATH with a (custom) installation of python, go to Window -> Preferences -> PyDev -> Interpreter - Python. That's where you can add your custom installation of Python as a preset and select its environment paths that are to be included in the PYTHONPATH for that interpreter preset (make sure you don't include the project's source paths themselves, Eclipse will add them when you run the project).

Once done, go to your project preferences and select the newly created interpreter preset from the list (PyDev - Interpreter/Grammar).

You will get code-completion as long as you use the PyDev editor(s) and have your PYTHONPATH environment correctly set-up.

Hope that helps.

猫烠⑼条掵仅有一顆心 2024-12-17 17:01:57

您可以使用 PyDev 远程调试功能并从 python 程序调用一些 pydev 调试器代码来调试外部 python 进程。 PyDev 网站上有记录:
http://pydev.org/manual_adv_remote_debugger.html#remote-debugger

You can debug an external python process by using the PyDev Remote debugging functionality and calling some pydev debugger code from your python program. This is documented on the PyDev website:
http://pydev.org/manual_adv_remote_debugger.html#remote-debugger

溺渁∝ 2024-12-17 17:01:57

这是我的工作代码。按照 bossi 所说的进行编译和操作,并将 .exe 添加为 Eclipse 中的 python 解释器,并确保在 Windows 环境变量 PATH 中包含包含 nessesary dll 的文件夹。

int wmain(int argc, wchar_t **argv)
{

    ScriptManager scriptManager; // This initialises Python. Python_Initialize()...

    int mainResult = Py_Main(argc, argv);


    return mainResult;
}

This is my working code. Compile and do as bossi said and add you .exe as python interpreter in Eclipse and make sure to have the folder with your nessesary dll's in windows environment variabel PATH.

int wmain(int argc, wchar_t **argv)
{

    ScriptManager scriptManager; // This initialises Python. Python_Initialize()...

    int mainResult = Py_Main(argc, argv);


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