How to force pydev output to pydev console? - pydev

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.

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 inspect variables form interactive console in PyDev

How can I run code in the Interactive Console in PyDev and see the created variables in the Variables view?
I am looking for the same functionality available in Spyder. If I am interactively running a script or just testing pieces, I would like o be able to see all the available shell variables and their respective values in the variables view.
I have already checked "Connect console to Debug Session" in Preferences > Pydev > Interactive console.
But when I run, say, a=1, the "Variables" view will be in italic for a moment and nothing appears there.
ANSWER
Following Fabio's advice: I updated Pydev from v5.4 to 5.8. That did it.
Not sure what's happening there.
For me, after checking Connect console to Debug Session in Preferences > PyDev > Interactive console, I do see created variables in the variables view.
Are you actually using the interactive console (i.e.: started with Ctrl+Alt+Enter)?
Can you show a screenshot with Eclipse on that situation?
Which PyDev version are you using?

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}

Pydev: execute a file in the console

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')

Ipython in pydev interactive debugging console(eclipse)

I have ipython working in pydev when using the normal interactive console, however when entering debug mode the console reverts to the standard pydev console. If I close this console and re-open it, ipython returns and I can use it as normal. Am I missing something, or is this a bug?
-Eric
Actually since PyDev version 3.0 you can attache a IPython console to a debug-session:
http://pydev.org/manual_adv_interactive_console.html#full-debug-support-in-interactive-console
To enable that feature, go to window > preferences > PyDev > Interactive Console and check 'Connect console to Debug Session?'.
Then only hassle is that you have to re-open a new IPython-console every time you re-launch the program in debug-mode.
Actually, Eclipse itself can have multiple consoles open at the same time... if you want, you can create multiple console views and pin a different console to each view (if you don't pin the console, one console will be shown on top of the other and you'll have to do the switching from one to the other manually).
As it is now, the debug console is not the same as the interactive console (it's a simpler version because of issues with the eclipse integration, although there are plans to be able to attach an interactive console to a debug session).
So, what you described is what should really happen (not really a bug).