我正在研究一个django项目,它有一个大型夹具,不能加载:
$ python manage.py loaddata apps/mainsite/fixtures/test_auctions.json
/Users/cp/bidsite/.ve/lib/python2.6/site-packages/django/db/models/fields/subclassing.py:80: DeprecationWarning: A Field class whose get_db_prep_save method hasn't been updated to take a `connection` argument.
new_class = super(SubfieldBase, cls).__new__(cls, name, bases, attrs)
/Users/cp/bidsite/.ve/lib/python2.6/site-packages/django/db/models/fields/subclassing.py:80: DeprecationWarning: A Field class whose get_db_prep_lookup method hasn't been updated to take `connection` and `prepared` arguments.
new_class = super(SubfieldBase, cls).__new__(cls, name, bases, attrs)
/Users/cp/bidsite/.ve/lib/python2.6/site-packages/celery/task/schedules.py:5: DeprecationWarning: celery.task.schedules is deprecated and renamed to celery.schedules
"celery.task.schedules is deprecated and renamed to celery.schedules"))
Problem installing fixture 'apps/mainsite/fixtures/test_auctions.json': Traceback (most recent call last):
File "/Users/cp/bidsite/.ve/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", …Run Code Online (Sandbox Code Playgroud) 如果我在ipython %pdb启用魔法的情况下运行代码并且代码抛出异常,是否有任何方法可以告诉代码继续执行?
例如,说例外是a ValueError: x=0 not allowed.我可以在pdb中设置x=1并允许代码继续(恢复)执行吗?
我在wince7设备上调试我的应用程序.
几分钟后,我收到一个错误:"没有为任何调用堆栈帧加载符号.源代码无法显示."
我注意到在模块列表中我有1个dll缺少pdb文件.它的名字是System.Drawing.dll.我注意到在创建了一些线程(我没有创建,我不知道是谁)之后,模块被添加到模块列表中.
我只是在线程运行后才收到错误.
任何人都知道我在哪里可以找到所需的pdb文件?(我已经尝试修复.net紧凑框架)
如何找出线程的起始位置?(我在代码中找不到它)
接下来我该怎么办?
请帮忙
我希望post_mortem()在遇到异常时让我的调试器运行,而不必修改我正在处理的源.我看到很多例子涉及在try/except块中包装代码,但我想让它始终运行,无论我在做什么.
我研究了一个python包装器脚本,但是它变得丑陋且几乎无法使用.
我使用pudb,它与pdb的API等价,所以pdb特定的答案很好.我在我的编辑器(vim)中运行代码,并希望在遇到异常时让pm出现.
听起来我错过了一些非常简单的东西,我试图在我的python代码中使用以下命令设置断点:
if(some condition):
pdb.set_trace()
Run Code Online (Sandbox Code Playgroud)
我的代码中的错误是在大量迭代之后出现的......难以使用print等进行调试.当条件命中时我能够打印东西但是我想设置brk-pt.
- 编辑 -
实际代码:
import pdb
if (node_num == 16):
print node_num
pdb.set_trace()
Run Code Online (Sandbox Code Playgroud) 当我运行我的Python调试器时,我可以进入我编写的函数.但是,如果我尝试进入类似的库函数os.mkdir("folder"),例如,它会"跨越"它.有没有办法进入内置库函数,看看Python正在做什么?
理想情况下,有一种方法可以在PyPy中执行此操作,以便您可以继续深入研究Python代码.
我正在运行最新版本的ipdb 0.10.0,当我使用nosetests插件运行我的django测试套件时,一旦我打了一个import ipdb; ipdb.set_trace()电话,我就看不到提示了.
我已经尝试在nose args中添加一个'-s'参数,它显示了提示,但没有正确捕获它们在ipdb中的键盘输入.例如,我使用向上和向下箭头键丢失输入历史记录.
最后,我再次尝试使用ipdb 0.9.3,它运行正常.
我想知道是否有任何方法可以使用最新版本的ipdb来解决这个问题?有新的配置机制吗?
在Python中,有没有办法在使用PDB进行调试时显示线程/进程ID?
我在看https://docs.python.org/2/library/pdb.html但找不到与之相关的任何内容?
考虑以下两个示例:
x = 1; y = 2; z = 3
Run Code Online (Sandbox Code Playgroud)
和:
for i in range(3): print(i)
Run Code Online (Sandbox Code Playgroud)
在后者中,如果在像pdb这样的调试器中逐步进行调试,则它将print(i)在循环的每次迭代时停止在。
但是,在第一个示例中,它停止了一次。
进一步调查,分解多语句行,我们发现实际上第一行有两个条目co_lnotab。但是dis.dis()谎言。
至于对循环有只是在一个行lnotab,但你停在每个互为作用的地方,偏移10,是在一个跳转的目标。那么,即使行号没有更改,是什么触发了停止操作?
import dis
>>> x = compile('x = 1; y = 2; z = 3', 'foo', 'exec')
>>> x.co_lnotab
b'\x04\x00\x04\x00'
>>> dis.dis(x)
1 0 LOAD_CONST 0 (1)
2 STORE_NAME 0 (x)
4 LOAD_CONST 1 (2)
6 STORE_NAME 1 (y)
8 LOAD_CONST 2 (3)
10 STORE_NAME 2 (z)
12 LOAD_CONST …Run Code Online (Sandbox Code Playgroud) 当我尝试在Jupyter Notebook中调试我的代码时,%debug我点击了"最旧的帧".
> $HOME/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py(244)_xy_from_xy()
242 if x.shape[0] != y.shape[0]:
243 raise ValueError("x and y must have same first dimension, but "
--> 244 "have shapes {} and {}".format(x.shape, y.shape))
245 if x.ndim > 2 or y.ndim > 2:
246 raise ValueError("x and y can be no greater than 2-D, but have "
ipdb> up
> $HOME/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py(385)_plot_args()
383 x, y = index_of(tup[-1])
384
--> 385 x, y = self._xy_from_xy(x, y)
386
387 if self.command == 'plot':
ipdb> up
> …Run Code Online (Sandbox Code Playgroud)