如何通过pycharm实现远程代码的调试和开发

写在前面

前段时间去总部出差,实现一个功能的交接工作,因为分公司的网络和总部的内网有所隔离,并且远程安装的系统为centos server版本,所以调试bug比较困难。于是打算通过pycharm远程连接到服务器上,通过同步本地和服务器代码进行远程调试。

环境准备

默认的开发语言是python,那么python开发的一个重要事项是包管理。想想那么多负责的包,如果没有好的包管理系统,在本机搭建一个包环境是多么复杂。于是放弃了本地构建包的想法——使用远程包。
pycharm作为一款强大的IDE,很好的实现了这个功能。

    1. 点击file->settings,找到如图示所示的页面(project Interpreter),点击下拉框后边的设置图标,能找到红框标识的选项,点击“Add Remote”。

      图示1.png
  • 2.这里选择ssh这种方式连接,这块没什么好说的,按照要填写的信息填写好点确定就ok了。

    图示2.png
  • 3.上述这部完成后还需要注意一个细节,看下图,这里需要把这个也给设置了,这个就是需要把你本地的工程和远程的工程对接起来。

    图示3.png
  • 4.分别按照步骤将local path和remote path选择好。其中local path对应本地的工程位置,remote path对应要连接的工程的位置。

    图示4.png
  • 5.设置完后得到的结果如下,然后点击ok退出设置。

    图示5.png

至此,等待IDE加载完这些包,包环境已经搞定了,这时候点击运行已经能执行了,看到下图的执行结果说明配置成功了。这个时候,不管是运行还是调试,运行调用的环境和代码都是远程的了,打断点调试也可以执行了。(注意: 这里的本机代码必须和服务器代码相同,否则断点可能不是期望的那个断点位置。)

图示6.png

更进一步

上面已经能满足远程调试的需求了,但是调试意味着要修改一部分代码。前面调试注意点说到要统一两边的代码,那么问题来了,我们该一两行代码,难道要用ssh来回改文件么?其实不用!接着往下看。

  • 1.创建开发模式的sftp连接。设置位置如下图:

    图示7.png
    1. 点击加号,弹出下框,名字自己填,type下拉选择sftp,弹出框后,按照需求把相关的字段填好。如图示9所示。

      图示8.png

      图示9.png
  • 3.完成图示9的操作时候,不要着急关闭,选择红框所示的右边的“Mappings”这个标签页,把红框标识的两个路径选择好,还是第一个是本地工程的路径,第二个路径是远程服务器上面的工程路径。完成图示10,此时可以点击ok。

    图示10.png

搞定上述的那些操作,就可以随意的修改代码和远程代码进行随意同步了。

图示11.png

这里改了一部分代码,只需要点击右键,然后选择下图的选项,两边的代码就同步了。

图示12.png

ok,从现在开始,像本机一样开发吧。

作者:如烟花非花
链接:http://www.jianshu.com/p/79df9ac88e96
來源:简书

网友评论42


    Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  1. 0楼
    Adidas NMD XR1 Ostrich Color and Black:

    An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he the truth is bought me breakfast because I discovered it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to debate this, I feel strongly about it and love reading extra on this topic. If possible, as you become expertise, would you mind updating your weblog with extra details? It is extremely helpful for me. Big thumb up for this blog post!

    2018-03-20 上午6:41

  2. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  3. 0楼
    Payday Express:

    advance cash <a href="https://advancecash.us.org">advance cash</a> advance cash <a href=https://advancecash.us.org>online payday advance</a>

    2018-03-20 上午8:05

  4. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  5. 0楼
    yeezy boost 350:

    You made some decent points there. I appeared on the internet for the issue and found most individuals will associate with together with your website.

    2018-03-20 下午3:05

  6. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  7. 0楼
    Michael Kors Fulton Leather Large Blue Satchels:

    I actually wanted to construct a brief note to appreciate you for all of the wonderful guides you are giving here. My prolonged internet look up has at the end of the day been recognized with reputable points to share with my guests. I would believe that many of us website visitors actually are undeniably blessed to live in a fantastic site with many brilliant professionals with beneficial concepts. I feel very lucky to have discovered your webpages and look forward to many more thrilling times reading here. Thank you again for all the details.

    2018-03-20 下午6:15

  8. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  9. 0楼
    JamesCak:

    chat with girls <a href="https://girls.us.org">girls</a&gt; girls <a href=https://girls.us.org>girls</a>

    2018-03-21 上午4:19

  10. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  11. 0楼
    JamesCak:

    cheap car insurance quotes <a href="https://carinsurance.us.org">compare auto insurance rates</a> compare car insurance <a href=https://carinsurance.us.org>compare car insurance quotes</a>

    2018-03-21 上午6:34

  12. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  13. 0楼
    adidas ultra boost 3.0:

    I am typically to blogging and i really recognize your content. The article has actually peaks my interest. I am going to bookmark your website and preserve checking for new information.

    2018-03-21 下午6:43

  14. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  15. 0楼
    JamesCak:

    help with writing essays <a href=https://collegeessay.us.com>college essay</a> writing a college essay about yourself <a href=https://collegeessay.us.com>need help writing essay</a>

    2018-03-22 上午3:28

  16. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  17. 0楼
    JamesCak:

    compare car insurance rates <a href="https://autoinsurancequote.us.com">car insurance quote online</a> rental car insurance <a href=https://autoinsurancequote.us.com>auto insurance quote</a>

    2018-03-22 上午7:13

  18. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  19. 0楼
    JamesCak:

    auto insurance quotes <a href="https://autoinsurancequotes.us.com">car insurance quotes comparison</a> auto insurance quotes <a href=https://autoinsurancequotes.us.com>auto insurance quotes comparison</a>

    2018-03-22 上午8:14

  20. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  21. 0楼
    nike huarache:

    I and also my pals ended up examining the excellent guides on the website while the sudden developed a horrible suspicion I had not thanked the web blog owner for those tips. Those people happened to be absolutely joyful to learn all of them and have now absolutely been loving those things. I appreciate you for turning out to be so helpful and also for finding varieties of awesome subject matter millions of individuals are really wanting to understand about. My personal honest apologies for not expressing appreciation to you earlier.

    2018-03-22 上午10:26

  22. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  23. 0楼
    JamesCak:

    cash advance <a href="https://cashadvance.us.org">cash advance no credit check</a> payday advance <a href=https://cashadvance.us.org>cash advance lenders</a>

    2018-03-23 上午12:55

  24. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  25. 0楼
    yeezy boost 350:

    This actually answered my downside, thank you!

    2018-03-23 上午1:20

  26. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  27. 0楼
    Loans:

    loan application online <a href="https://loanapplication.us.com">loan calculator personal</a> loan application <a href=https://loanapplication.us.com>faxless loans</a>

    2018-03-23 上午6:21

  28. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  29. 0楼
    Payday:

    advance cash loan <a href="https://advancecash.us.org">payday advance</a> best loan rates <a href=https://advancecash.us.org>cash advance</a>

    2018-03-23 上午9:30

  30. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  31. 0楼
    nike air max:

    I wish to voice my passion for your kind-heartedness supporting persons that actually need help on this one content. Your personal commitment to passing the message all around turned out to be extremely significant and has usually permitted people much like me to attain their desired goals. Your personal useful help implies a lot a person like me and somewhat more to my office colleagues. Best wishes; from each one of us.

    2018-03-23 上午11:01

  32. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  33. 0楼
    yeezy boost 350:

    I抎 need to check with you here. Which isn't something I often do! I get pleasure from studying a submit that may make people think. Additionally, thanks for permitting me to comment!

    2018-03-24 上午4:31

  34. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  35. 0楼
    JamesCak:

    best online loans instant approval <a href="https://loansinstantapproval.us.com">loans instant approval</a> online quick loans <a href=https://loansinstantapproval.us.com>instant loans online</a>

    2018-03-24 上午5:16

  36. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  37. 0楼
    ysl handbags:

    Thank you a lot for giving everyone remarkably spectacular possiblity to discover important secrets from this web site. It can be very beneficial plus full of amusement for me personally and my office colleagues to visit the blog the equivalent of 3 times a week to learn the latest issues you have got. And indeed, I'm just at all times impressed considering the mind-boggling methods you give. Selected 1 facts in this post are truly the most impressive we have ever had.

    2018-03-24 下午12:21

  38. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  39. 0楼
    Webcam Porn Live:

    milf cams <a href="https://cams.us.org">cams</a&gt; teen masturbation cam <a href=https://cams.us.org>amateur cams</a>

    2018-03-24 下午9:25

  40. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  41. 0楼
    Quick Loan:

    cash advance <a href="https://advancecash.us.org">american financial loans</a> cash advance usa <a href=https://advancecash.us.org>credit loans for bad credit</a>

    2018-03-25 上午6:27

  42. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  43. 0楼
    Get A Loan:

    loan lenders <a href="https://loanlenders.us.com">loan lenders</a> loan lenders <a href=https://loanlenders.us.com>bad credit loans direct lenders</a>

    2018-03-25 上午8:02

  44. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  45. 0楼
    JamesCak:

    college essays <a href="https://essay.us.org">argument essay</a> essay writer <a href=https://essay.us.org>argumentative essay</a>

    2018-03-25 上午8:07

  46. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  47. 0楼
    yeezy boost:

    My spouse and i ended up being now glad that John could do his researching because of the ideas he made while using the blog. It's not at all simplistic just to find yourself giving out information and facts which often people today could have been trying to sell. We really know we need you to give thanks to for that. The entire illustrations you made, the straightforward web site menu, the friendships your site help to create - it's got most unbelievable, and it is letting our son in addition to the family do think the content is excellent, and that's pretty essential. Thanks for everything!

    2018-03-25 上午8:11

  48. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  49. 0楼
    JamesCak:

    payday loans in san antonio <a href="https://loanservices.us.com">loan application online</a> loan site <a href=https://loanservices.us.com>loan services</a>

    2018-03-25 上午10:36

  50. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  51. 0楼
    Payday Loans Online:

    payday loans bad credit <a href="https://badcreditloansguaranteedapproval.us.com">bad credit loans direct lenders</a> bad credit installment loans guaranteed <a href=https://badcreditloansguaranteedapproval.us.com>loans in tucson</a>

    2018-03-25 上午10:45

  52. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  53. 0楼
    longchamp:

    I definitely wanted to post a quick message so as to express gratitude to you for the precious ways you are giving out on this site. My considerable internet lookup has finally been compensated with excellent tips to talk about with my relatives. I would express that many of us readers are truly blessed to exist in a magnificent website with very many lovely people with insightful secrets. I feel rather privileged to have discovered the web site and look forward to some more awesome minutes reading here. Thanks once more for a lot of things.

    2018-03-25 下午12:41

  54. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  55. 0楼
    Cam Chat:

    live pussy <a href="https://girls.us.org">chat with girls</a> girls <a href=https://girls.us.org>free webcam girls</a>

    2018-03-25 下午5:28

  56. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  57. 0楼
    Payday Loan Online:

    loan sites <a href="https://loansonline.us.org">loans online</a> best online loans <a href=https://loansonline.us.org>online loan</a>

    2018-03-25 下午9:01

  58. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  59. 0楼
    JamesCak:

    compare auto insurance rates <a href="https://autoinsurancequotes.us.com">compare car insurance rates</a> progressive auto ins <a href=https://autoinsurancequotes.us.com>auto insurance quotes</a>

    2018-03-25 下午9:04

  60. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  61. 0楼
    Money Loan:

    one hour payday loan <a href="https://lenders.us.com">direct lender installment loans</a> personal loans 100 approval <a href=https://lenders.us.com>lenders</a>

    2018-03-26 上午3:37

  62. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  63. 0楼
    Free Xxx Webcams:

    sex chat <a href="https://chat.us.org">adult chat rooms</a> free erotic <a href=https://chat.us.org>sex chat rooms</a>

    2018-03-26 上午7:34

  64. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  65. 0楼
    kobe 9:

    I just wanted to write a word in order to appreciate you for these amazing items you are giving out at this website. My considerable internet lookup has now been rewarded with sensible insight to talk about with my great friends. I would express that we visitors are unequivocally blessed to live in a notable site with so many outstanding individuals with valuable methods. I feel rather blessed to have used your entire weblog and look forward to tons of more thrilling moments reading here. Thanks a lot again for everything.

    2018-03-26 上午8:16

  66. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  67. 0楼
    adidas ultra boost:

    Youre so cool! I dont suppose Ive read something like this before. So good to search out somebody with some authentic ideas on this subject. realy thanks for beginning this up. this website is something that is needed on the net, someone with a little originality. helpful job for bringing one thing new to the internet!

    2018-03-26 上午8:41

  68. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  69. 0楼
    adidas eqt:

    My spouse and i felt so fortunate John managed to round up his preliminary research by way of the precious recommendations he had in your web site. It is now and again perplexing to simply happen to be freely giving tactics some people have been trying to sell. And we also keep in mind we have got the writer to thank for that. The type of explanations you have made, the simple website menu, the friendships your site help instill - it is everything spectacular, and it's helping our son in addition to us consider that this article is interesting, which is certainly extraordinarily serious. Thanks for all!

    2018-03-26 下午12:30

  70. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  71. 0楼
    Online Payday Loans:

    bad credit loans guaranteed approval <a href="https://badcreditloansguaranteedapproval.us.com">bad credit loans guaranteed approval</a> bad credit loans guaranteed approval <a href=https://badcreditloansguaranteedapproval.us.com>payday loans ga</a>

    2018-03-26 下午1:23

  72. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  73. 0楼
    JamesCak:

    indiana payday loans <a href="https://creditloans.us.com">credit loans</a> bad credit loan <a href=https://creditloans.us.com>credit loans guaranteed approval</a>

    2018-03-26 下午5:20

  74. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  75. 0楼
    Dildo Show:

    camsluts <a href="https://chat.us.org">chat</a&gt; theonlymisshugeboobs adult webcam <a href=https://chat.us.org>chat live</a>

    2018-03-26 下午7:00

  76. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  77. 0楼
    Live Free Sex Chat:

    webcam <a href="https://webcam.us.org">chatbazaar no registration</a> free web cams <a href=https://webcam.us.org>free adult webcam chat rooms</a>

    2018-03-27 下午3:04

  78. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  79. 0楼
    goyard handbags:

    I am commenting to make you be aware of what a outstanding discovery my cousin's princess experienced reading your blog. She figured out numerous things, not to mention how it is like to have a marvelous coaching heart to have the others with no trouble fully understand some hard to do issues. You truly exceeded visitors' expectations. I appreciate you for rendering those effective, healthy, revealing and in addition easy tips about the topic to Sandra.

    2018-03-27 下午4:56

  80. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  81. 0楼
    Webcam Sex Chat:

    live chat <a href="https://sexcam.us.com">sex cams</a> sex cam <a href=https://sexcam.us.com>freesexcams</a>

    2018-03-27 下午5:36

  82. Warning: Division by zero in /www/wwwroot/www.ctoclubs.com/wp-content/themes/Loocol/functions.php on line 243
  83. 0楼
    JamesCak:

    aaa car insurance quote online <a href="https://carinsurancequotescomparison.us.com">car insurance quotes comparison</a> car insurance quotes comparison <a href=https://carinsurancequotescomparison.us.com>car insurance quote</a>

    2018-03-27 下午6:35

发表评论

您必须 [ 登录 ] 才能发表留言!