Make eclipse_debug.py work - eclipse

(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.

Related

need help in VSCODE debug

I'm a VSCODE first-time user. I tried to run debug on a simple python file and was not successful. I got 2 strange results:
the debug tool bar showed and disappeared instantly
no local variables was shown in VARIABLE section
Please see the screenshot.
Anyone could give me a hint anything was missing in what I did?
You need the python vscode extension to debug a python file. When you press F5 to start debugging, a menu will ask you what you are trying to debug. Click on Python File. The python extension creates a launch.json file for you and starts the debugger.
I noticed the Run and Debug tab is in your screenshot. Click that tab above where the variables would be shown and it should ask you to create the launch.json file in order to debug the file.
Read more on debugging and launch configurations for python here: https://code.visualstudio.com/docs/python/debugging

How to replicate the following Spyder behavior in VSCode?

I'm new to coding Python in VSCode. Previously I used Spyder but decided to move to VSCode as the project management seems better in it (I could easily switch to other files/folders by clicking on the path, just like in PyCharm). But I really need this one workflow which I still have not managed to do it in VSCode.
write some codes like Selenium.
Click run (F5)
The selenium browser opens up.
I could use the Ipython terminal to access the code interactively (find the element in the browser etc) and send new command.
I would like to have this workflow in VSCode. Im also quite overwhelmed by the difference in these 2 IDEs, for example, in VSCode, you have integrated terminal, a debugging console and an output tab, while im used to have only one-for-all Ipython tab.
Ok, I figured out what I need. Basically I just need to right click on the python file that I want to run on the side bar. Then I have to select 'run current file in interactive window'. The only difference is on the Ipython console, I have to use shift+Enter to send my input instead of just clicking enter. But its not a big deal.

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}

eclipse debug perl curses

I am writing a Perl program that uses curses for output and move the cursor, and color characters. Previously, when I was working under windows I use Komodo it was able to run an external console.
Now I work in Linux environment and use eclipse + epic. If you try to just run the script, it uses the internal console eclipse, which is very cut. You can just run the script using external tool, but I'm interested to debug using external console window. Is this possible?
Unfortunately, use of a File and /dev/pty/1 does not help in solving my problem.
The fact is that in this case it is impossible to get the characters introduced in the console through curses getch(). Always returned 1 instead code of pressed key.
Here is an answer that will take you most of the way (based on post #6 of: http://ubuntuforums.org/showthread.php?t=743131, although since then, in the "Indigo" and "Juno" versions of Eclipse, things have changed somewhat, and this answer is up to date):
Go to "Run -> Debug configurations". Click on the (fourth) "Common" tab. Go to the third frame from top, and there, check-mark the checkbox which says: "File". Enter the file name of the console window you want your output in.

Whats the shortcut to Debug in PyDev using Eclipse

The shortcut key is F11 to start debugging. But issue is that I have to be on that file and then hit F11 to start debugging.
Eg.
my file to launch the application is "launch.py" and "example.py".
example.py is open in the editor whereas launch.py is not.
Now, if I hit F11 it will try to launch the application using "example.py" and terminates due to error (as expected).
So then I have to open the "launch.py" in the editor and then hit F11 to start debugging the application.
Is there any neater way to configure the debugging, so that it starts the application in single hit/key?
Edit: example.py is some other file (some module). It does not launch the application.
As this PyDev Eclipse Tutorial suggests:
After the first run, if you type Ctrl+F11, the last file ran is re-run. Or, if you type just F11, a debug session is started with your last run. Let's test this...
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application.
This tutorial will always consider this as the default option.
So, did you have this option selected?
If you have launch at least once launch.py, then you can re-launch it easily.
Although this isn't strictly an answer to what was asked initially, it might help someone looking here that had the same problem as me...
I'm a Java developer mainly, so have the Java view open almost all the time. However, sometimes I want to run some python file to test something (or just create a quick python script, and run it)...
In the Java editor, if the current class has a main(String[] args) method, I run it with (and popup the dialog to ask me what exactly I'd like to run in the middle)
alt+shift+x, j
Unfortunately, that doesn't work in the Python view, and I've not found a similar solution - it just asks me if I'd like to run it as a Java app... however, as the VonC says, you can run the last run thing (provided you've set the preferences accordingly) with
ctrl+f11
and this seems work well with python run configurations too.
But... What if the last thing I ran was a Java program, but I now want to run the active .py file? Previously, to run the .py file, I'd have to go digging through the buttons on the toolbar with the mouse, and I tend to prefer keyboard shortcuts...
Solution! So, finally I come to the actual useful bit of this answer - I just discovered by accident (typing Ivan's suggested shortcut, but missing!), it appears that
f9
will run the currently active python file.
Hope that helps someone get just that little bit faster...
I use CTRL+SHIFT+F9 to relaunch the previous debug configuration in Pydev.