问题
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.
回答1:
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.
回答2:
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
回答3:
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;
}
来源:https://stackoverflow.com/questions/7834870/eclipse-connect-to-custom-python-interpreter-with-pydev