Pydev: execute a file in the console - pydev

Is it possible to get pydev in eclipse to run a file in its console?
Example of what I would like to do:
1. hit ctrl-alt-enter
2. select console
3. open a python file
4. somehow run it in the console
5. inspect the results

You first need to open a console. See this page for a how-to: http://pydev.org/manual_adv_interactive_console.html
You then have two choices:
>>> runfile(r'/path/to/my/file.py')
or
>>> execfile(r'/path/to/my/file.py')

Related

How to see the results in IPython Console- Spyder

I'm new to spyder and I'm trying to run the code written in the editor but the IPython console isn't showing the results like it's supposed to. All it says is run file and then the file path. I have tried resetting the spyder default settings, restarting the kernel but it doesn't work. so I wrote some code in IPython console and it does work. I don't know where to see the output of my code and I don't know what's wrong.Image
I'm following a tutorial and it's supposed to be like this.Tutorial-Image
(Spyder maintainer here) The problem you're experiencing is caused because Spyder has several evaluation modes. The person in Tutorial-Image is selecting the code in the Editor with the mouse and then running it by pressing the F9 key. That's why you see in that image that the code written in the editor is pasted directly into the console.
In your case case, you're running the code by pressing the Run button (i.e. green play button) or the F5 key. And when do that, you need to add print statements to see its results in the console.
you didn't output anything in your file of code. use the following code to output what you want print
print("hello,world!")
# or
print(a+b) # the a + b was defined in your file of code
EDIT
I installed the spyder and run the code your mentioned.
The following output is

How to force pydev output to pydev console?

every running will output result to a new console like this:
I just wondering is it possible to output to pydev console(like below) by default
If you open the interactive console (i.e.: Ctrl+Alt+Enter), a subsequent use of Ctrl+Alt+Enter should run the current file in the console. See: http://www.pydev.org/manual_adv_interactive_console.html for more details.

Make eclipse_debug.py work

(In Windows 10, I have installed ...\AppData\Local\Enthought\Canopy that includes Python 2.7, %PATH% points to Canopy)
I have seen this link, and want to make interactively debug Python code running in PyXLL work via that eclipse_debug.py.
So I have done the following:
1) erase PYTHONPATH in the control panel of Windows (as a result, echo %PYTHONPATH% returns %PYTHONPATH%).
2) modify only the first line of eclipse_debug.py to be eclipse_roots = [r"C:\my_path_to\eclipse"].
3) add eclipse_debug.py to pyxll.cfg
4) define a function hello
5) launch debug servier in eclipse, and then launch Excel, and then reload PyXLL
Here is a screenshot:
1) So, it shows that the function hello does work.
2) However, I don't see any excel menu item related to debugger, whereas their link promises This module adds an Excel menu item to attach to the PyDev debugger, and also an Excel macro so that this script can be run outside of Excel and call PyXLL to attach to the PyDev debugger. In other words, I don't see how interactive debug is enabled here.
Could anyone tell me what this eclipse_debug.py supposed to do?
Well, from what I can tell by looking at it, eclipse_debug.py adds the PyDev Remote Debugger (http://www.pydev.org/manual_adv_remote_debugger.html) to the PYTHONPATH and starts it.
Now, how do you make a Python script such as eclipse_debug.py appear as a menu in PyXLL is something I'm not familiar with.
The most likely cause is that it's looking for pydevd but is unable to find it on your python path or where it's looking under the eclipse root. If that's the case there will be some output in the pyxll log file and that will be why the menu item is not appearing.
You should check the log file for errors, and hopefully that will tell you what is going wrong.

Call ./.../bin/spark-submit pythonfile.py in eclipse (Pydev) console when running program

Current situation which works fine:
I'm currently programming my Pyspark files in eclipse with the Pydev plugin
I manually execute these files in the ubuntu shell with the following command:
./.../bin/spark-submit pythonfile.py
Desired situation:
When I press the "run" button in eclipse, eclipse will call the command mentioned above and show the console output in the eclipse console.
Is this possible and if yes, could someone give me a clue on how to do it?
Thank you!
I would recommend an external launch.
From the Run menu, choose External Tools | External Tools Configurations... and then create a launch configuration specifying the command you want to run.
You can generalize the command a little by using Variables For example:
Location: ${workspace_loc:/myprojectname}/../bin/spark-submit
Working Directory: ${workspace_loc:/myprojectname}
Arguments: ${workspace_loc:/myprojectname/myscript.py}
This is what a screenshot of the configuration looks like.
Additionally, in the Common tab you have a control over whether the output is captured in a console (the default) and/or redirected to a file. In this example screenshot, the output comes to a console and is written to a file back in my project:
Output file: ${workspace_loc:/myprojectname/build_output}

Running Coffeescript snippets directly in Aptana Studio 3

Right now I am playing around with CoffeeScript and I loved to see that Aptana now supports it natively. But I am unable to "Run" the Script directly in Aptana to get the results printed to the built-in console.
When i click Ctrl+R as described in the CoffeeScript Bundle I only get a git-help information printed in the console.
For Example
script.coffee
console.log "Hello Coffee"
When I run it through the terminal by typing
$coffee script.coffee
I get the result printed perfectly.
I can't find any documentation or hints for solving this problem.
Am I missing something ?
There is an open ticket here and a brief discussion here.
If this is your issue (look at the console if you get this 'line 3: pre: command not found' error), then a temporary solution I found is to edit Aptana Rubles/coffeescript.ruble/commands/run.rb (located in ~/Documents in a linux installation) and remove ' | pre' from line 11.
After that, restart Aptana or reload the Coffeescript bundle from Bundles View (right-click on it->reload), select the text (will work only if there is selected text) and press Ctrl-R + 1. You should now see a new html file with the 'Hello Coffee' in it.
Hope this helps.