简体   繁体   中英

Cleanest way to run/debug python programs in windows

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

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.

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.

Year 2017-2019 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

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.

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)

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

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!?

如果你毕业于vim,你可以运行以下命令来启动你当前在交互式shell中编辑的程序:

:!python -i my_script.py

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... ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM