So I spend almost all of my programming time on Linux, but recently, for a project, I had to try out PTVS and WPF. As it is a very good framework, I would like to learn it further, but the issue in question is a huge disadvantage when compared to running python programs on Linux.
So say I have a little WPF project on IronPython2.7, with some buttons and some functions handling those buttons' click events. The problem is that not every exception/error present in that code is shown in debugger: sometimes it just says "the process exited with code 0x01". That, for example, happens if I try to access an array element outside of array bounds.
The question is: is there a way to fix this and be able to see all the errors and exceptions while debugging a WPF program?
By default, IronPython projects in Visual Studio run using the managed debugger. This makes it really easy to debug mixed Python/.NET code, however, you don't get quite as nice an experience when you only have Python code.
To change this, right-click your project in Solution Explorer and select Properties. On the Debug tab, there's a dropdown for the launcher - you can see a screenshot here.
It's probably got IronPython (.NET) launcher selected, but changing it to Standard Python launcher should give you better pure-Python debugging. The downside is that you won't be able to step into .NET code anymore, and it's a little bit more invasive. In general though, the improvements are worth it if you are not using IronPython to extend a .NET application.
Related
I recently started working with Java and I really like to auto-correction / completion features in IntelliJ.
Does it exist something similar and as powerful for python?
I presume you are using JetBrains IDE so you could try out their PyCharm for python. It's from the same company so I presume that PyCharm's autocomplete features are on par with that of IntelliJ
As I never used IntelliJ, the recommendations below are based on the autocomplete features of PyCharm.
I was using tabnine on vs code and it does support many ide's however I stopped using it now since it is using too much resources on my laptop and I feel that auto complete is kind of distracting (but that is just my opinion). You could also try Github's Copilot, my friend uses it but for reasons mentioned earlier, I didn't try it. These two however, may not be the autocompletes you are looking for as they can basically write your code for you.
Can we use any IRONPython editor to develop scripts for Tibco Spotfire controls.
Can we use IDLE editor to develop IRONPython scripts for Tibco Spotfire? If yes then how to integrate the tibco module with IDLE editor, Can anyone help on this??
You should be able to use any development tool (ide) which supports ironpython. One of the best in my point of view is PTVS (Python Tools for Visual Studio), just search for it. But when you want some thing very lightweight with only some syntax hilighting, i prefer using Visual Studio Code or Atom. But PTVS has a lot of nice features. One of the most important ones are those for debugging, because they prevent you from using some console printing or some thing similar as debugging tool. Just take a look at it.
EDIT
As far as i can see, it should work just fines with PTVS. Taking a look at this, is't just some API as any other api: API-Doc
Spotfre has its own IDE for developing scripts but it is very poor one when analysing its functionalities. I dont think you can use any IDE to debug the scripts but you can at least use the one suggested by BendEg to make creation of the code more 'pleasant'.
Spotfire uses IronPython, which is a .NET implementation of python. In other words, is .NET driven by python. To test simple python functions, you can use CodeSkulptor, a cloud based python interpreter. For IronPython, you can use this java based online version but again, this is to test simple scripts
I've recently moved from Matlab to Python. Python is a much better language (from the point of view of a computer scientist), but Python IDEs all seem to lack one important thing:
A proper interactive debugger.
I'm looking for:
The ability to set breakpoints graphically by clicking next to a line of code in the editor.
The ability to run ANY CODE while stopped in the debugger, including calling functions from my code, showing new windows, playing audio, etc.
When an error occurs, the debugger should automatically open an interactive console at the error line.
Once done with the interactive console, you can resume normal execution.
Matlab has all these features and they work incredibly well, but I can't find them anywhere in Python tools.
I've tried:
PyCharm: the interactive console is clunky, often fails to appear, and crashes all the time (I've tried several different versions and OSs).
IPython: can't set breakpoints -Launching a Python console programatically: you have to stop your code, insert an extra line of code, and run again from the beginning to do this. Plus, you can't access functions already imported without re-importing them.
Being able to debug and fix problems THE FIRST TIME THEY APPEAR is very important to me, as I work in programs that often take dozens of minutes to re-run (computational neuroscience).
CONCLUSION: there is NO way to do all of these in Python at the moment. Let us hope that PyLab development accelerates.
At the top of your code, write
import pdb
And within your code, use the following statement wherever you want to debug.
pdb.set_trace()
You will have an interactive shell thus, whenever the set_trace() statement is met.
You can then use step(s), next(n), continue(c) and so on to check the execution flow, and print values of variables like print var
For more details on pdb, refer here
There are many Python IDEs. That was a topic here: What IDE to use for Python?
"The ability to set breakpoints graphically by clicking next to a line of code in the editor."
PyDev has this. Double-click in the gray margin bar.
"The ability to run ANY CODE while stopped in the debugger, including calling functions from my code, showing new windows, playing audio, etc."
PyDev has this. It's not the only one. PyScripter's stated features seem to include this.
"When an error occurs, the debugger should automatically open an interactive console at the error line."
PyDev does this. (I think. Or at worst do you need to double-click on the console message that states the error's location in the code?)
"Once done with the interactive console, you can resume normal execution."
PyDev has this. It's called "resume". It's what the green "play" triangle in a toolbar does. Some other software calls this feature "continue".
I've been searching for the same, but unfortunately Python IDEs are not as well-featured as Matlab's at this point. For scientific programming, you will also want graphics/plotting to run in an entirely different thread, so IPython integration is essential. As far as I can tell, the Matlab IDE feature to change the workspace from the debugger, which then affects code running subsequently, is quite unique. Each of the features exist in some IDE, but none exist in all:
Spyder has good integration with scientific tools, but its debugging is limited to the built-in pdb, which lacks the requirement to execute any code and have this code affect the namespace after continuing.
PyDev and PyCharm, and quite a few others, have decent debugging features, but I don't think it has good integration with scientific tools. That means, if you plot, you lose access to your prompt. Not good.
As far as I've experienced, the closest comes Wing IDE. It is a propietry product, but if you're making the transition from Matlab 89$/year for non-commercial-use should be acceptable (you can evaluate it first). But for me, I've ultimately settled to alter my workflow, and not using any sophisticated IDE at all. When I looked was some years ago, so perhaps the situation has improved.
You might also be interested in this article from April 2013, Evaluating IDEs for Scientific Python. It doesn't really reach a conclusion either.
Seeing as you are comming from Matlab, I would suggest you give a look at
Python(x,y)
The page decribes it as follows:
Python(x,y) is a free scientific and engineering development software for numerical computations, data analysis and data visualization based on Python programming language, Qt graphical user interfaces and Spyder interactive scientific development environment.
It will not cater to all your wishes, but it certainly made me feel comfortable when I started out with Python, coming from Matlab.
Hope it helps
You can do all this in the iPython Notebook. Use the magic command %pdb to stop on error.
If using the command line,
alias ipythondebug='ipython --InteractiveShell.pdb true'
in your ~/.profile will give you debug on error like Matlab. This of course requires ipython installed.
Not sure about the resuming part.
You can also edit the ipython config file if you want the debug on error to be permanent. See
https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pdb
Are there any IDEs for Python that support automatic error highlighting (like the Eclipse IDE for Java?) I think it would be a useful feature for a Python IDE, since it would make it easier to find syntax errors. Even if such an editor did not exist, it still might be possible to implement this by automatically running the Python script every few seconds, and then parsing the console output for error messages.
eclipse+pydev
pycharm
many others ....
If you use VIM or don't have a problem with it, try this extension. https://github.com/klen/python-mode
This is for Emacs as well: https://github.com/gabrielelanaro/emacs-for-python
Also pycharm and eclipse with pydev work fine.
If I don't use vim I really enjoy spyder. It is easy to use and has some really nice features, like integrated debugging and profiling, graphical variable explorer and object inspector. The latter shows, e.g., the integrated documentation for every function of class you use.
I built an extension to Eclipse and PyDev that does what you describe, it runs the Python code as you're typing, and displays all the variable values and any exceptions that occur. It's called Live Coding in Python, and the web site has a tutorial and a demo video.
PyDev can highlight some problems in your code by analysing it, and Live Coding in Python can show you problems that happen when you run it.
I have a C++ application (on Windows XP) that invokes some Python code. I currently use Winpdb as my python debugger.
Using winpdb as the debugger has some disadvantages since firstly, I need to add a pdb statement, and there is little control afforded to me during the execution since I add dynamic breakpoints.
Does anyone know of tools that can be used that work in a similar fashion to Visual Studio 2010 (or Visual Studio in general)? Most important for me is to be able to set up and remove breakpoints while the application is executing, much like we can do using Visual Studio.
I have looked at ActiveState Komodo IDE6 and Eclipse Python PyDev, but I do not think either one actually fits the bill. This is because I have various python modules that are initialized
using the C++ function call "Py_InitModule" with a name that might be different from the name of the .py file. There modules are not recognized by Komodo and Eclipse Python PyDev.
Please let me know if you have any suggestions. Thank you for your help.
Well, for me it seems that it'd work in PyDev... The only thing is that you have to attach the tracing to the debugger -- use pydevd.settrace(suspend=False) on the thread you want to trace and after that it should 'synchronize' the current breakpoints and their additions/removals ( more references: http://pydev.org/manual_adv_remote_debugger.html ) -- note that you could use pydevd.settrace(suspend=True) to work as a breakpoint as in in pdb.
I didn't really understand why you said it wouldn't work. Can you post your specific example of what's not working to see how that would be solvable? (some things may be customized in pydevd_file_utils.py to help in translating breakpoint paths).