Python Editor and Debugger on Windows

Environment: WIN7 / WINXP
Python Version: Python-2.7.3

You can get the python installing file from the official website. (Python-2.7.3.msi )
After that, just click it to install python. It's recommended that you config the PATH
on windows Environment for the reason you can run the `python` command in different
paths.

 

Python 2.7 and networkx [1]

-------------------------------------

matplotlib and numpy : scientific computing tools for python

matplotlib-1.1.0.win32-py2.7.exe                       =>http://sourceforge.net/projects/matplotlib/
numpy-1.6.2-win32-superpack-python2.7.exe => http://sourceforge.net/projects/numpy/files/

setuptools :

setuptools-0.6c11.win32-py2.7.exe                  =>http://pypi.python.org/packages/2.7/s/setuptools/

networkx :

Just follow the guide on the Home Pageof networkx, it can be easy to install the package.
For me, i follow the steps:
            1. Download networkx-1.7.zip                 =>http://networkx.lanl.gov/download/networkx/
            2. Start the `cmd` windows, change directory to “networkx”
            3. Run “python setup.py install” to build and install.
More details can be get from the page http://networkx.lanl.gov/install.html

 

Python Win

----------------

This is an editor for windows users. You can get the package from the sourceforge.net .
pywin32-217.win32-py2.7.exe => http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/
If you are familar with VC6.0 programming, you can find that all the debug shortcutkeys (F5, F10, F11)
just follow the custom.

 

Ulipad

---------

wxPython : Unicode support

wxPython2.8-win32-unicode-2.8.12.1-py27.exe=> http://wxpython.org/download.php

comtypes :

comtypes-0.6.2.win32.exe
             => http://surfnet.dl.sourceforge.net/project/comtypes/comtypes/0.6.2/comtypes-0.6.2.win32.exe

ulipad (either .exe or .zip)

ulipad.4.1.zip or ulipad.4.1.py27.exe => http://code.google.com/p/ulipad/downloads/list

After install the packages above, we should config the ulipad.
            Ulipad->编辑->参数->Python->设置Python解释器->增加
            输入解释器路径 可以手动选择python安装文件夹下的python.exe文件  描述设置为2.7.1 console
            再新增个python文件夹下的pythonw.exe 描述为2.7.1 window 确定即可 执行python程序了

Relevant Q.

            1. When using winpdb to debug .py file, typeeval() orexec() on theCommand Input Bar, than
                you can trace the variable or compute the expressions.

            2. If you choose .exe file to installulipad 4.1, it can be wrong when you start the program. Fault
                warning like 'R6034,C runtime Library 未正确加载' may be displayed. I don't know the internal
                reason, but ulipad 4.0 may work.

            3. Sometimes, winpdb of ulipad "*** Failed to find script."  Upgrading the winpdb can be one way
                to solve it. I use winpdb 1.4.8 to replace the default version under the ulipad setup folder. 
                ( Replace the filesrpdb2.pyand winpdb.py under ulipad/packages/winpdb with new ones.)

 

Sublime Text 2

--------------------

Just down the newest version 2.0.1 from the Home Pagehttp://www.sublimetext.com/.
The sublime has binded the python interpreter. But i would still like to use the python interpreter myself.
So i new a build system, paste the following code on file python27.sublime-build :

{ 
    "cmd": ["C:\\Python27\\python.exe", "-u", "$file"], 
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", 
    "selector": "source.python" 
}

I do not find any plugin to support .py file debug. However,pdb is rather a good tool, which is embeded
in python interpreter. To learn how to use pdb, we take a simple program for testing :

def main():
  low, high = 0, 1
  for i in xrange(10):
    print high
    low, high = high, low + high

if __name__ == '__main__':
  main()

Assuming the filename is fib.py, we can run the program in pdb using the following command:

$ python -m pdb fib.py

 

The best pdb tip

If you put the following snippet somewhere in your program and run it normally, execution
will stop and a debugging session will start when this line is reached:

import pdb; pdb.set_trace()

More details can be seen in http://aymanh.com/python-debugging-techniques.

 

Winpdb still work here. After you install python, follow winpdb intalling process given by
http://winpdb.org/download/.Suppose the objective .py file to debug is 'default.py', then
1. Edit default.py and add the following code to the top

 import rpdb2
 rpdb2.start_embedded_debugger('pw')

2. Start winpdb
3. Start debuggin session
    In WinPDB, select File->Password and enter "pw" (no quotes)
    Select File->Attach. You should see your running script in the list box along with its PID and filename.
    Select your script and click OK. The debugger is now attached to your script.
More details can be found in http://wiki.xbmc.org/index.php?title=How-to:Debug_python_scripts_with_WinPDB

 

REFERENCE:

[1] http://bbs.sciencenet.cn/home.php?mod=space&uid=544369&do=blog&id=417112
[2] http://www.cnblogs.com/myx/archive/2011/12/07/2280015.html
[3] http://aymanh.com/python-debugging-techniques
[4] http://wiki.xbmc.org/index.php?title=How-to:Debug_python_scripts_with_WinPDB

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值