您好,欢迎访问三七文档
当前位置:首页 > 建筑/环境 > 建筑材料 > 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:PyfileonRemotePCPyfileonLocalPCc.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
本文标题:MS VS Code for Python debug
链接地址:https://www.777doc.com/doc-4516836 .html