Pycharm远程调试环境配置

1. 环境:

系统环境:win7
软件环境:pycharm 3.1.1 

2. 将client端(实际程序执行的环境)的代码所在的路径映射到server端(IDE):

Remote path-代码所在的client端路径是:/home/lovecat/branches/transcoder2.0/src/transcoder/src

Local path-映射到本地server端的路径是:N:/branches/transcoder2.0/src/transcoder/src 

3. 在server端(IDE)和client端(实际程序执行的环境)都安装上 pycharm-debug.egg:

pycharm-debug.egg在server端pycharm安装目录下
安装命令:

    easy_install pycharm-debug.egg

 4. 配置server端:

4.1 打开Edit confiurations 
 

4.2 新增一个python remote debug配置:

Local Host Name:server端的ip地址
Port:任意一个不和其他程序冲突的端口
Path Mappings:server端和client端代码所在路径的映射

Local path:参考 【2-Local path】
Remote path:参考 【2-Remote path】
 

 5. 配置client端:

在需要调试的代码开头加上以下代码:

host:server端的ip地址,参考【4-Local Host Name】
port:server端设置的调试环境的端口,参考【4-Port】
stdoutToServer:when this is true, the stdout is passed to the debug server
stderrToServer:when this is true, the stderr is passed to the debug server

    import pydevd

    pydevd.settrace(host='192.168.1.203', port=2315, stdoutToServer=True, stderrToServer=True)

 6. 启动调试环境:

6.1 启动server端:

 

 6.2 启动client端: 

client端启动成功后,server端会有如下输出:
 

 7. 调试:

在server端映射的代码打上断点即可进行调试

 

 

发布了22 篇原创文章 · 获赞 2 · 访问量 1万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章