I am developing something in Python in Eclipse PyDev. Per the instructions from my assignment, I need to run this program like so:
PYTHONPATH=../:. python grade_analysis.py
However I am just running the program with the standard Run button and (no surprise) it's not working correctly. It is a unit test that claims it runs 0 tests.
Does anyone know how to run this specific file with that pythonpath in Eclipse PyDev? I've been playing with settings in the Run Configuration and no luck
You have to configure those paths to be source folders inside of PyDev (a source folder is the folder that should be in the PYTHONPATH).
See: http://www.pydev.org/manual_101_project_conf2.html for details.
Related
I have a module that is part of a library I am writing. The library has multiple executables. These are run from the command line as a script with the syntax python3 -m mypackage.mysubpackage.MyModule
I am familiar with eclipse, its debugger and PyDev, but I have not found how to set a debug/run configuration to launch MyModule within PyDev.
I have tried to add -m or -m mypackage.mysubpackage.MyModule as VM arguments to python.exe within the Arguments section of the Debug Configuration, but this does not work even setting the appropriate working directory to have mypackage in the PYTHONPATH.
I know how to launch the program outside eclipse and connect it to eclipse using a debug server. I know I can also make a little auxiliary script that is not part of the library just to launch the program so I can run it inside eclipse, but I would prefer the convenience of being able to launch the module directly within eclipse itself and I feel PyDev should be able to do this.
If you just press F9 PyDev should launch your module.
Although note it'll launch the file directly. If you require it to be launched with the -m flag (so that your relative imports resolve in that file), you can configure it in the preference:
preferences > PyDev > Run > Launch modules with python -m ...
PyDev will compute the module name based on the file location and PYTHONPATH configured in this case.
p.s.: You may want to take a look at http://www.pydev.org/manual_101_run.html for more details on re-launching your module, unit-tests, etc.
I am using a the NetBeans 7.x IDE. I have a Netbeans Application module. I use the Build and the Run buttons from the IDE. The module runs just fine when I press Run Project or F6 button. I like to run
this from the command line. Since everything was build automatically for
me I have no idea where things are or how to run it. There are several jar files in the project/build/public-package-jars. Is there a way to see what command and options the Run Project is using ?
Go to the root of the application (or wherever there is a build.xml file) on the command line and run ant -p. That will list all of the available options for building and running the application.
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.
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.
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
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;
}
I am a beginner in using Eclipse and PyDev (Aptana Studio 3). I am not used to and i don't understand the workflow in such big IDEs as Eclipse.
I have a simple task: i have a simple Python script, which i want to open and run in Eclipse, having its output in Eclipse console. Or debug it.
Until now i used another IDE called Eric4, which allowed me to do what i want - open a file and run immediately, without creating a project or setting up launch configurations.
Is this possible in Eclipse, or i have to create a project for each file i want to run or debug? I want to understand how it works.
I guess i understand that creating a project is needed at least for settings up the paths (PYTHONPATH), but if it's a single script - somehow to use by default the current directory?
For example i have a folder called snippets where i keep a lot of python scripts which demonstrate some functionality. How do i open these files one by one and run them?
Most of my coworkers launch python scripts in a separate console - python my_scipt.py.
You need to have at least one project with the configuration you want (i.e.: syntax type, interpreter), then, open the file you want to run and press F9.
If it's an external file -- i.e.: a file that's not under a project in Eclipse -- it'll ask you to associate a project with the launch to get the needed information for the launch, but the file doesn't really have to be in the project (note that you can drag external files from your filesystem into Eclipse to open them).
I suggest you follow the steps on the getting started: http://pydev.org/manual_101_root.html (it guides you to configuring PyDev and explains how to do a run/debug session).
I have installed pylint via easy_install. I can run pylint <filename> with success. But pydev refuses to use it.
I checked "use pylint"
I configured correct path
I updated my python interpreter in eclipse to have pylit in pythonpath
I use Eclipse Galileo
I have build automatically checked
I tried cleaning whole project and no errors
What am I doing wrong?
I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.
Project->Properties->PyDev-PYTHONPATH
add relevant folders to the list of sources.
I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:
http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329
http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332
As if nobody writes scripts in Python... Grumble grumble...
To provide an alternative solution, pylint can be used as an External Tool in Eclipse. This requires having previously installed the pylint package for a Python installation.
Remember to first have a pylintrc file somewhere where pylint can find it, failing which a "No config file found" error is printed. Typically I would touch pylintrc inside the project directory, and keep the file in version control. For reference, see pylint command-line options.
In Eclipse, select Run, External Tools, External Tools Configurations.... Click the toolbar button to create a New launch configuration. Configure as below or as desired:
Name: pylint
Location: ${system_path:pylint}
Working Directory: ${project_loc}
Arguments: --reports=n "${resource_loc}"
Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.
The output of the external tool will by default be printed to the console.
Related: Setting up pep8 as an External Tool in Eclipse