MS VS Code for Python debug

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Author:KevinZhangThisdocumentdescribesDebugging:RemoteDebugingindetail1.Download/InstallPython2.InstallMSVSCodeDownloadfromitsofficialwebsiteItsupportswindows,LinuxandmacOS3.InstalltheextensionRestartVScodeisrequiredaftertheextensioninstallationdone.4.ConfigurePythonextensiona.LaunchMSVSCodeb.Press‘Ctrl+Alt+P’,andentered‘setting’c.Suggestedconfigurationseditor.renderWhitespace:boundary,editor.renderControlCharacters:true,editor.renderIndentGuides:true,IfyoudidnotaddpythonfoldertoyourOSpathenvironment,update‘python.pythonPath’python.pythonPath:D:/ProgramFiles(x86)/python3.5/python.exe-MyconfigurationfileNote:Installedflake8Enabled,lintingby’pipinstallxx’commandbeforeyouconfiguredtheminconfigurationfile.5.Localdebuga.OpenafolderwhichcontainsyourPyfiles//MSVScodedebuggingdependsonProjectb.Setbreakpointsc.DebuggingPress‘F5’andselect‘Python’Itpromptsyoutosetuplaunch.jsonfirstLocatelaunch.jsonfilefromtherootofyoufolderJustignorethepromptif#4.C:python.pythonPathisconfiguredproperly.PressF5again:6.RemoteDebuggingEnvironmentdescription:RemotePC:RunPyscriptWindows2008R2,IP10.10.5.16Pyfilepath:C:/Users/Administrator/Desktop/QA_PyScript/uitestkz.pyVSCodeisnotnecessary,Python/PTVSDisrequired.LocalPC:AttachtoremotePCfordebugwindows10,IP:10.10.4.30Pyfilepath:D:/temp/Dropbox(NT)/KevinSelf/ST/uitestkz.pyVScode/Pythonisrequireda.InstallPTVSDonbothLocal/RemotePCpipinstallptvsdb.EditPythonscriptandimportthelibraryimportptvsdptvsd.enable_attach(my_secret,address=('0.0.0.0',3000))ptvsd.wait_for_attach()#EnablethebelowlineofcodeonlyifyouwanttheapplicationtowaituntilthedebuggerhasattachedtoitNote:Maketheabovechangeinbothscriptfiles(i.e.scriptsonboththelocalandremotePC).However,ontheclientside,ensuretheabovethreelinesarecommentedoutI.e.thisisnecessarytoensurewehavethesamelinenumbersontheserverandtheymatch.Sample:PyfileonRemotePCPyfileonLocalPCc.Editlaunch.jsononLocalPCasfollows:{name:remote,type:python,request:attach,localRoot:${workspaceRoot},remoteRoot:C:/Users/Administrator/Desktop/QA_PyScript/,port:3000,secret:my_secret,host:10.10.5.16}d.DebuggingStartPythonscriptonremotePCAddabreakpointandattachlocalPCtoremotePCDebuggingworks,For‘SourceUnkownSourceisnotavailable.’,ithasbeenmentionedin#302,#507

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功