python之ipdb模块

python调试模块ipdb详解 ipdb是用来python中用以交互式debug的模块,可以直接利用pip安装,这篇文章主要介绍了python调试模块ipdb详解,需要的朋友可以参考下。 阅读详情

授人以鱼不如授人以渔,掌握调试方法是学习提升的一个必备条件。前几天因为探索了一下 Python 模块引入路径的问题,看到「翔 Core」用 pdb 调试的很溜,因此,今天研究一下 ipdb好啦。

安装

ipdb 是 pdb 模块的升级版,会启动一个 ipython 的调试窗口。

pip install ipdb

使用

python -m ipdb demo.py 直接运行程序,不需要再程序中去插入内容;
import ipdb;ipdb.set_trace(),这种用法需要在程序内部插入语句,类似插入「断点」的效果;
帮助文档

在 ipdb 窗口,输入 h ,会看到帮助文档,h 可以查看具体命令的帮助。

Documented commands (type help <topic>):
========================================
EOF    cl         disable  interact  next    psource  rv         unt
a      clear      display  j         p       q        s          until
alias  commands   down     jump      pdef    quit     source     up
args   condition  enable   l         pdoc    r        step       w
b      cont       exit     list      pfile   restart  tbreak     whatis
break  continue   h        ll        pinfo   return   u          where
bt     d          help     longlist  pinfo2  retval   unalias
c      debug      ignore   n         pp      run      undisplay

Miscellaneous help topics:
==========================
exec  pdb

常用命令

a(rgs):打印当前函数的参数列表 ★★★
b(reak) [ ([filename:]lineno | function) [, condition] ]:设置断点,可以接行数或者行数名作为参数,比如,b 8 就是在第8行打断点,还可以给外部的文件加上断点 b file_name:line_number,如果只敲 b ,会显示全部断点
c(ont(inue)):继续执行,当遇到断点时才会停止 ★★★
cl(ear) filename:lineno :可以清除断点,不过不加「断点号」,可以清除所有断点
disable bpnumber [bpnumber …] :禁用指定[断点号]的断点
enable bpnumber [bpnumber …]:启用指定[断点号]的断点
Enter:重复上次命令 ★★★
j(ump):设置下一步执行的行,这个语句可以让你跳过某些语句的执行,并不是网上一些文章说的跳到某行,跳到某行可不是代表会跳过某些语句的,文档最准确
ll or l:查看当前将要运行的代码段
n(ext):让程序运行下一行,如果当前语句有一个函数调用,用 n 是不会进入被调用的函数体中的 ★★★
pp expression or p expression:前者以 pprint 方式打印表达式的值,后者 print 方式 ★★★
q(uit):退出调试,同时,你也可以使用 Ctrl D退出调试
r(eturn):继续执行,直到当前函数返回 ★★★
restart “restart” is an alias for “run”. :是 run 命令的别名,重新启动调试器;
run [args…] :这里的参数会作为运行脚本的参数,等价于 python demo.py [args…],可以通过 sys.argv 查看参数列表,重新运行时,断点等信息会保留的
s(tep):和 n 相似,但是如果当前有一个函数调用,s 会进入被调用的函数体中 ★★★
w(here):打印一个堆栈跟踪,
! :感叹号后面跟着语句,可以直接改变某个变量的值
示例

断点示例

下面是一个关于断点的示例:
执行 b 7、b 12 之后,输入 ll 查看,最左侧的 1、2 就是断点号,输入 c ,下次运行到断点处,执行就会停下来。

ipdb> ll
----> 1 a = 'michael'
      2 print(a)
      3
      4 def (name):
      5     print('hello')
      6     for i in range(5):
1     7         print(i)
      8     print(name)
      9
     10
     11 hello('michael')
2    12 x = 10
     13 y = 20

执行 disable 1,下次执行到「断点1」处,就不会停下来了,输入 b 可以查看全部断点:

ipdb> b
Num Type         Disp Enb   Where
1   breakpoint   keep no    at /Users/michael/Code/00-Temp/b.py:7
2   breakpoint   keep yes   at /Users/michael/Code/00-Temp/b.py:12

如果想清除「断点2」,那么执行 cl 2 即可:

ipdb> cl 2
Deleted breakpoint 2 at /Users/michael/Code/00-Temp/b.py:12

run 示例

ipdb> run --name michael
Restarting b.py with arguments:
	--name michael
> /Users/michael/Code/00-Temp/b.py(1)<module>()
----> 1 a = 'michael'
      2 print(a)
      3

ipdb> import sys
ipdb> sys.argv
['b.py', '--name', 'michael']

看到上面的结果,确实等价于 python b.py --name michael。

注意点

在 ipdb 调试窗口,虽然可以随时给变量赋值,但是要注意变量的名字和 ipdb 的命令不能重复了,否则会出错,可以用 !b=123 来规避这个问题。

遇到这个错误:

AttributeError: 'module' object has no attribute 'processor'

网上有相关问题:

https://stackoverflow.com/questions/1250103/attributeerror-module-object-has-no-attribute
主要是两种常见的错误会造成这个:
1)模块命名和标准模块命名冲突了;
2)循环引用

分析

搜索项目中哪些地方引入 platform

grep -rIin 'import platform'

同时,还可以在使用 platform.processor() 方法前面加上 print(paltform.file)

查看启动 Python 时,就自动加载的模块:

python -v

或者

import sys
sys.modules['platform']

查看运行编包命令时,加载的模块:

python -v /usr/bin/pkg

将以上输出对比了一下,先排除标准模块会引入 platform ,因为标准模块,一般都是「自包含」。然后和 python -v 对比,发现编包命令多加载了一个第三方 blessings 模块,是不是它引入 platform 的呢?

发现,正常的构建机器上,这个模块是 1.6.1 版本,而目前发现问题的机器,这个包版本是 1.7 版本。那么,来看看,他俩之间的差异:

Github-erikrose/blessings包,点击分支,查看 Tag 1.7 的提交记录,发现了这个提交

from platform import python_version_tuple

1.7 版本中,这一行删除了,所以发生了差异。

根本原因:

pkgutil.iter_modules(package.__path__)

相关问题

SOF-AttributeError: ‘module’ object has no attribute

最后学完这个 ipdb 的调试,再回头看看 Pycharm 的 debug 功能,貌似都能理解了!

【GLM5】手把手教你在openclaw中白嫖英伟达羊毛 openclaw很强,但是也很贵,每一次请求都会消耗大量的token。而英伟达平台正好可以白嫖免费的模型,于是,我们一拍即合。 阅读详情

相关推荐

佳能C3025打印机扫描方法

佳能C3025彩色打印机扫描方法 步骤一、如果打印机处于休眠状态,可按图中标记的按钮唤醒打印机; 然后点击屏幕上的【扫描】 步骤二、扫描类型选择【文件】 步骤三、点击屏幕上的【地址簿】 步骤四、此时屏幕胡看到名字,如果看不到自己的名字,可往下滑动直到看到自己的名字,然后点击自己的名字,再点击右下角的【应用】 步骤五、点击【发送设置】,可看到文件格式为PDF,点击可以选择JPEG的图片格式。...

weixin_46019317的博客 2万+

【Python 脚本报错】AttributeError:'module' has no attribute 'xxx'的解决方法

最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本正常的,但执行报错”AttributeError: ‘module’ object has no attribute ‘xxx’”,其实是.pyc文件存在问题。 问题定位:查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件。 问题解决方法:删除该库的.pyc文件,重新运行代码;或者找一个可以运...

quokka 28万+

7系列ZYNQ硬件调试:Vitis无法识别ARM DAP的排查与解决

本文针对7系列ZYNQ开发中Vitis无法识别ARM DAP的典型硬件调试问题,提供了系统性的排查与解决方案。文章深入剖析了问题本质,指出ARM DAP无法访问的核心原因在于PS部分的电源、时钟或复位等硬件基础条件未满足,并重点强调了PS参考时钟(如33.333MHz晶振)的完整性是关键排查点。通过从电源完整性、时钟与复位信号到JTAG连接与焊接的逐步硬件排查,并结合软件配置交叉验证,为开发者提供了清晰的故障定位思路与实战指南。

weixin_29280657的博客 624

python遇到AttributeError: module ‘XXX‘ has no attribute ‘XXX‘的错误

错误原因: 主要的原因看可能有两个: 1、检查一下有没有拼错函数,有时候写的快了真的有可能手误; 2、如果没拼错那就检测一下该模块的函数是否是更新了,因为python的第三方库是时常会更新的,有时候函数名会有轻微的变动这也很正常,解决方法就是查看一下对应版本下的官方文档,看看该函数是否发生变动了 3、如果经过前两步还是没错,那么就很有可能是你的python文件命名与你使用的第三方库一样导致的错误,...

Rio小哥的博客 4万+

Argoverse2数据集保姆级导入教程:从下载到预处理全流程解析

本文详细解析了Argoverse2数据集的完整导入流程,从环境配置、数据下载到预处理和高效加载策略。作为自动驾驶领域的标杆数据集,Argoverse2提供多模态传感器数据和高精地图信息,帮助研究者快速搭建数据处理流水线。文章包含实用代码示例和性能优化技巧,特别适合自动驾驶算法开发者参考。

weixin_29035405的博客 331

深入浅出CenterFusion

结合论文和代码理解CenterFusion

Untitled的专栏 5101

Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法 2014年04月30日 ⁄ 测试工具, 软件测试 ⁄ 共 678字 ⁄ 字号 小 中 大 ⁄ 暂无评论 ⁄ 阅读 12,782 次 最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本正常的,但执行报错"A

八月的专栏 4万+

Cadence公司的数字IC设计工具:综合工具(Genus)——(2)

介绍Cadence公司的数字IC设计工具Genus

qq_42922513的博客 1943

python出现AttributeError: module ‘xxx’ has no attribute ‘xxx’错误时,两个解决办法...

运行python程序时,也许会出现这样的错误:AttributeError: module ‘xxx’ has no attribute ‘xxx’:解决该错误有两种方法 1、手动安装该模块 2、检查文件名 这个方式看起来很傻,但是却是新手经常会犯的错,原因是因为自己的文件名称和要使用的模块重名了,只需要更改文件名即可。 转载于:https://w...

weixin_30773135的博客 1万+

从电商平台到微信私域:构建合规跳转链路的技术实现

在互联网营销与用户增长领域,链接跳转是连接不同平台、引导用户流量的基础技术。其核心原理是通过服务器端路由与参数解析,实现用户请求的接收、处理与重定向。这项技术的价值在于能够突破平台间的生态壁垒,实现流量的合规、可控迁移,尤其适用于跨平台营销、私域沉淀等场景。在实际应用中,常需处理微信环境限制、参数传递与动态内容生成等挑战。本文聚焦于电商平台(如淘宝)到微信生态的跳转需求,详细阐述了如何利用Node.js、Express框架及二维码生成技术,构建一个包含环境检测、参数传递与动态落地页的完整跳转系统,以解决微信

weixin_33889665的博客 322

Xilinx UltraScale+系列FPGA实现USB3.0 DEV 设备 部分原理图+代码分享

Zynq UltraScale+ MPSoC 系列是 Xilinx 新一代 Zynq 平台。在 FPGA 里有完整的 ARM 处理(PS),包含了四核或双核 Cortex-A53 处理器 ,处理器子系统中有DDR内存控制器等大量的外设,在FPGA中完全独立于可编程逻辑单元(PL)如果暂时没有用到PL部分,PS也能单独工作,相当于可以当成一个ARM来用了(以前的不行)。 ARM也包含USB3.0控制器,这是实现USB3.0DEV的关键,根据官方手册(ug1085)描述,USB主(Host)从(Device)

Pierre 1万+

python遇到AttributeError: module ‘XXX‘ has no attribute ‘XXX‘的错误,解决办法

例如:你用了cv2的库,即有import cv2 的语句,而你这个程序的文件名也是cv2.py的话,那么当你使用cv2.imshow()的时候其实是调用你自己写的程序而不是真正的cv2库,因此当然会报has no attribute 'XXX’的错误啦。(很有可能是自己写的参数与官方文档规定的参数不一致,请参考官方文档中的函数是规定了传递什么参数)解决方法就是改文件名就行啦。

m0_52883102的博客 1万+

大唐杯5G考前冲刺篇(回顾全文重点必看)

大唐杯习题复习指南

nimo观察者 1万+

python调试模块ipdb浅谈

ipdb是用来python中用以交互式debug的模块,可以直接利用pip安装,这篇文章主要介绍了python调试模块ipdb详解,需要的朋友可以参考下。

xiaoweids的博客 247

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

python调试模块ipdb

ipdb是用来python中用以交互式debug的模块,可以直接利用pip安装;其功能类似于pycharm中 python控制台,而使用ipdb 的优点,便是直接在代码中调试,避免了在python控制台,或者重新设置一些简单变量。

chumingqian的博客 646

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

初次使用python(2)之如何下载ipdb模块

上次提到了ipdb这个python中用于进行调试的模块,但在python中是额外的package。所以,这篇文章写得是如何下载ipdb模块。        在Windows环境中,需要用pip来下载所有模块。        1.安装pip         我们仍需要在python官网上找到pip文件,下载地址是:点击打开链接  点击黄色部分进行下载,然后把压缩包解压,我解压到了py

Evabook的博客 4296

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

IPython Debugger (ipdb) 详解,python debug调试模块

(IPython debugger), 与类似, 是一款集成了 IPython 的 Python 代码命令行调试工具,支持等。

分享学习期间的笔记心得 2783

python第三方库ipdb(debug模块)

本博介绍了python第三方库ipdb模块

Jimmyzqb的博客 4043

ipdb调试命令简介

目录参考 参考 Python 调试模块 ipdb

shidahu的专栏 2485

#6 ipdb模块源代码解读

前言 好久不见,大家最近可好????。通过前几节的学习,相信你已经掌握了面向对象的大量知识,但是光知道是不够的,需要自己多写、多看,学一门语言无非不过这两种秘诀嘛。因此本篇博文带着大家剖析一次源代码,剖析对象为代码调试模块:ipdb。为什么选择这个模块呢?因为下一次的博文计划写Python代码调试的啦~~Go!!! 一、ipdb介绍 1.1 ipdb介绍 ipdb是一款调试代码的第三方...

ab420036723的博客 442

ipdb模块源代码解读

一、ipdb介绍 1.1 ipdb介绍 ipdb是一款调试代码的第三方模块 我想这一句话就给出了ipdb的所有信息了哇 1.2 ipdb安装 既然是第三方模块,那么就需要自己来安装,使用pip即可,在命令行输入: 如果你对python感兴趣,我这有个学习Python基地,里面有很多学习资料,感兴趣的+Q群:688244617 pip install ipdb 测试安装是否成功,在命令行输入: ...

weixin_45342712的博客 1422

Python的功能模块[4] -> pdb/ipdb -> 实现 Python 的单步调试

pdb / ipdb 模块 / pdb / ipdb Module pdb 和 ipdb 的主要作用是用于 Python 程序的单步调试,Python 的调试可参考链接。 下面是一个简单的使用示例 1 import ipdb 2 3 i = 0 4 while i<100: 5 print(i) 6 ipdb.set_trace(...

weixin_30273931的博客 182

Python调试技巧

调试是 Python 开发中的重要环节,它能够帮助我们发现和修复代码中的问题。Python 提供了多种调试工具和技术,从基础的打印调试到强大的调试器工具。以下是一些常见的 Python 调试技巧:

weixin_44617651的博客 1399

【python】如何将ipdb的python解释器路径切换至虚拟环境中

背景: 利用virtualenv构建一个python3.5的虚拟环境,在该虚拟环境中使用ipdb调试程序,结果报错找不到某一个模块。 程序的所有依赖模块都已经成功安装在虚拟环境中。 在虚拟环境中,terminal跳转至程序所在目录,使用ipdb开始调试。 ipdb table_baxter_her.py 当运行至如下位置时出现报错, 使用pip尝试查找clic...

weixin_30338743的博客 313

#7 Python代码调试

前言 Python已经学了这么久了,你现在已经长大了,该学会自己调试代码了!相信大家在编写程序过程中会遇到大量的错误信息,我也不例外的啦~遇到这些问题该怎么解决呢?使用最多的方法就是使用print打印中间变量了哇,关于这种方法怎么说呢~low!!!这一节将记录Python中一项很重要的技能:Debug(代码调试),Here We Go! 一、代码调试概述 1.1 概述 一个程序员...

ab420036723的博客 632

Python 代码调试技巧(pdb、ipdb、debugpy)与 Debugger 工作机制

Python 提供了多种调试工具,从简单的pdb到功能强大的debugpy,每种工具都有其独特的应用场景。选择合适的调试工具可以显著提高开发效率。希望本文能帮助你更好地理解和使用这些工具。```

2501_91139723的博客 914
上一篇: 特征提取之pd.get_dummies()用法
下一篇: Pythorch中torch.nn.LSTM()参数详解
那记忆微凉
博客等级 码龄9年 412粉丝 387原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值