简体   繁体   English

PyDev调试

[英]PyDev Debugging

My interpreter is the python 2.6 interpreter that comes with cygwin. 我的解释器是cygwin附带的python 2.6解释器。

I have a pydev project that contains a linked folder. 我有一个包含链接文件夹的pydev项目。 In the folder, due to outside constraints, I have two sub-folders, one with a bunch of scripts I develop, and one which serves as the run directory for all my run configurations. 在文件夹中,由于外部限制,我有两个子文件夹,一个包含我开发的一堆脚本,另一个用作所有运行配置的运行目录。

When I run the project (not debug) everything works fine. 当我运行项目(而不是调试)时,一切正常。

However, when I choose to debug the project, my custom modules aren't found, and the import fails. 但是,当我选择调试项目时,找不到我的自定义模块,导入失败。

I tried adding my scripts folder to PYTHONPATH, but that didn't help, and when I printed sys.path It contained weird stuff, all of the form: 我尝试将我的脚本文件夹添加到PYTHONPATH,但这没有帮助,当我打印sys.path它包含奇怪的东西,所有的形式:

<path to run directory>/<path to entry in PYTHONPATH>

I can't make heads or tails out of it. 我无法做出正面或反面。

I'll appreciate any help. 我会感激任何帮助。

Unfortunately, that's a known issue. 不幸的是,这是一个已知问题。 PyDev does not support Cygwin for debugging. PyDev不支持Cygwin进行调试。 The primary reason is that the paths that Python reports don't match the paths you configure in windows, so, a translation step would be needed for each path (even some other areas such as code-completion or code-analysis could have problems). 主要原因是Python报告的路径与您在Windows中配置的路径不匹配,因此,每个路径都需要一个转换步骤(甚至其他一些区域,如代码完成或代码分析可能会出现问题) 。

You can probably do this translation yourself at eclipse/plugins/org.python.pydev_x.xx/pysrc/pydevd_file_utils.py (instructions on the file), but note that this may be more work than it's worth (the recommended approach is using a native Python install on Windows instead of through cygwin) -- or if you need an interpreter on Linux, develop on Linux :) 你可以在eclipse / plugins / org.python.pydev_x.xx / pysrc / pydevd_file_utils.py(文件说明)中自己做这个翻译,但请注意,这可能比它的价值更多(建议的方法是使用在Windows上安装本机Python而不是通过cygwin) - 或者如果你需要Linux上的解释器,在Linux上开发:)

Thanks, you made my day, its actually very easy, 谢谢,你做了我的一天,它实际上很容易,

you have to change the PATHS_FROM_ECLIPSE_TO_PYTHON variable inside pydevd_file_utils.py as, 你必须在pydevd_file_utils.py里面改变PATHS_FROM_ECLIPSE_TO_PYTHON变量,

PATHS_FROM_ECLIPSE_TO_PYTHON = [ (r'C:\\Users\\usernam\\workspace-cpp\\python-proj\\src', r'/cygdrive/c/Users/usernam/workspace-cpp/python-proj/src') ] PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'C:\\ Users \\ usernam \\ workspace-cpp \\ python-proj \\ src',r'/ cygdrive / c / Users / usernam / workspace-cpp / python-proj / src')]

But this needs to be changed for all your own python source files you desire to debug 但是这需要针对您想要调试的所有python源文件进行更改

I am happy to announce a new release of ePyUnit, which solves the load-path issue of 'pydevd.py'. 我很高兴地宣布ePyUnit的新版本,它解决了'pydevd.py'的加载路径问题。 This works from within Eclipse/PyDev as well as from an arbitrary process started from the command line. 这适用于Eclipse / PyDev以及从命令行启动的任意进程。

ePyUnit now includes the automation of remote debugging with PyDev and Eclipse by 'pydevd.py'. ePyUnit现在包括通过'pydevd.py'使用PyDev和Eclipse进行远程调试的自动化。 This works seamlessly for the 'subprocess' call as well as independently started command line processes. 这可以无缝地用于“子进程”调用以及独立启动的命令行进程。

See: 看到:

For basics of remote debugging: 有关远程调试的基础知识:

Also enhanced unittest integration into PyUnit. 还增强了unittest与PyUnit的集成。

Comments and fixes are welcome. 欢迎提出意见和解决方案。

Have fun... 玩得开心...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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