Cleanest way to run/debug python programs in windows
Asked Answered
M

9

24

Python for Windows by default comes with IDLE, which is the barest-bones IDE I've ever encountered. For editing files, I'll stick to emacs, thank you very much.

However, I want to run programs in some other shell than the crappy windows command prompt, which can't be widened to more than 80 characters.

IDLE lets me run programs in it if I open the file, then hit F5 (to go Run-> Run Module). I would rather like to just "run" the command, rather than going through the rigmarole of closing the emacs file, loading the IDLE file, etc. A scan of google and the IDLE docs doesn't seem to give much help about using IDLE's shell but not it's IDE.

Any advice from the stack overflow guys? Ideally I'd either like

  • advice on running programs using IDLE's shell

  • advice on other ways to run python programs in windows outside of IDLE or "cmd".

Thanks,

/YGA

Marthamarthe answered 15/1, 2009 at 4:1 Comment(3)
Duplicate: #1198, https://mcmap.net/q/53172/-what-ide-to-use-for-python-closed, #17989Mythical
@S.Lott: The question is what shell is the best for Python on Windows. You can answer this question with: "use such-and-such IDE", but it is not the only answer e.g., "python shell in Emacs" is an IDE kind of answer, but "Bozikovic's Console.exe and ipython" is not."Polyunsaturated
@S.Lott: And "shell" question is more specific than "environment" one.Polyunsaturated
G
33

For an interactive interpreter, nothing beats IPython. It's superb. It's also free and open source. On Windows, you'll want to install the readline library. Instructions for that are on the IPython installation documentation.

Winpdb is my Python debugger of choice. It's free, open source, and cross platform (using wxWidgets for the GUI). I wrote a tutorial on how to use Winpdb to help get people started on using graphical debuggers.

Glossology answered 15/1, 2009 at 4:49 Comment(2)
+1 for winpdb and +1000 for great tutorial. winpdb just builds on your pdb skills, while making debugging sessions way more pleasant.Haire
Well, I spent an hour trying to install this garbage and I still can't get it to work nor find anything online that tells you how to. Would it kill them to have an installer that actually puts everything together in the right place so it actually works?Zandra
D
9

You can easily widen the Windows console by doing the following:

  • click the icon for the console window in the upper right
  • select Properties from the menu
  • click the Layout tab
  • change the Window Size > Width to 140

This can also be saved universally by changing the Defaults on the menu.

Decastro answered 15/1, 2009 at 4:14 Comment(1)
You can also choose from one of EIGHT fabulous colors :)Nysa
G
6

Year 2017-2022 Answer:

Try Visual Studio Code, it has great support for Python debugging, auto completion and more!

See this link for details: https://code.visualstudio.com/docs/languages/python#_debugging

Greatniece answered 22/6, 2017 at 16:31 Comment(0)
N
3

However, I want to run programs in some other shell than the crappy windows command prompt, which can't be widened to more than 80 characters.

Click on the system box (top-left) in the command prompt and click properties. In the layout tab you can set the width and height of the window and the width and height of the screen buffer. I recommend setting the screen buffer height to 9999 so you can scroll back through a long output.

Nonfulfillment answered 15/1, 2009 at 4:7 Comment(0)
S
3

I use eclipse with pydev. Eclipse can be sluggish, but I've become attached to integrated svn/cvs, block indent/unindent and run as unittest features. (Also has F5 run)

If your comfortable in emacs though I don't see any reason to make such a major change.

I suggest instead that you replace your 'crappy command prompt' with powershell. It's not as crappy.

(As mentioned by Soviut and The Dark - you can increase the buffer width/window size to more than 80 by title-bar>right-click>Properties>Buffer Width/Window Size edit even in crappy cmd)

Seductress answered 15/1, 2009 at 5:56 Comment(0)
G
2

Wing IDE is awesome. They also have a free version.

Godewyn answered 15/1, 2009 at 4:3 Comment(1)
Is the debugger included in the free version?Fears
C
2

If you ever graduate to vim, you can just run the following command to start the program you're currently editing in an interactive shell:

:!python -i my_script.py
Ceto answered 15/1, 2009 at 5:31 Comment(0)
W
1

I edit my Python programs in EditPlus. I've configured a user tool that allows me to run my program and have its output appear in a frame below my editor window. My configuration will even let you double click on an exception lines in the output to jump directly to the file and line where the error occurred. You can grab the user tool configuration I use from here on the EditPlus wiki.

Perhaps there is similar functionality you can configure that allows you to run your program and display its output in your Emacs editor!?

Wicker answered 15/1, 2009 at 4:22 Comment(1)
EditPlus is a nice lightweight option.Shearwater
S
0

I replaced cmd with Cygwin and Poderosa. May be a little overkill though, if the only problem you have with cmd is that it's a pain to resize.

Although you use Emacs instead of Vim, so I guess you're into overkill... ;-)

Scurvy answered 25/3, 2009 at 1:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.