{"id":466,"date":"2021-12-28T15:49:47","date_gmt":"2021-12-28T07:49:47","guid":{"rendered":"http:\/\/www.theoldhero.com\/?p=466"},"modified":"2021-12-28T17:37:32","modified_gmt":"2021-12-28T09:37:32","slug":"%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%aepython2-x%e4%b8%8e3-x%e5%85%b1%e5%ad%98","status":"publish","type":"post","link":"http:\/\/www.theoldhero.com\/?p=466","title":{"rendered":"\u5982\u4f55\u8bbe\u7f6ePython2.x\u4e0e3.x\u5171\u5b58"},"content":{"rendered":"<h3><strong>1\u3001\u4e0b\u8f7dpython3\u548cpython2<\/strong><\/h3>\n<p>\u8fdb\u5165python\u5b98\u7f51\uff0c\u94fe\u63a5https:\/\/www.python.org\/<\/p>\n<p>\u9009\u62e9Downloads&#8212;&gt;Windows\uff0c\u70b9\u51fb\u8fdb\u5165\u5c31\u53ef\u4ee5\u770b\u5230\u5bfb\u627e\u60f3\u8981\u7684python\u7248\u672c<\/p>\n<h3><strong>2\u3001python3\u5b89\u88c5<\/strong><\/h3>\n<p><em>\u8bf4\u660e\uff1a\u672c\u6587\u5148\u5b89\u88c5python3\uff0c\u7136\u540e\u5b89\u88c5python2\u3002<br \/>\n\u5b9e\u9645\u5b89\u88c5\u4e0d\u5206\u5148\u540e\uff0c\u53ea\u662f\u540e\u5b89\u88c5\u7684\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u7cfb\u7edf\u73af\u5883\u53d8\u91cfPATH\uff0c\u4e0d\u53ef\u4ee5\u4f7f\u7528\u81ea\u52a8\u3002<\/em><\/p>\n<p>\u9996\u5148\u9009\u62e9\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982\u201cC:\\python3x\u201d\uff0c\u7136\u540e\u70b9\u51fb\u4e0b\u8f7d\u597d\u7684python3\u8f6f\u4ef6\u5305\u8fdb\u884c\u5b89\u88c5\uff0c\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p>\u5728\u4e0b\u56fe\u7ea2\u8272\u6807\u8bb0\u7684\u5730\u65b9Add Python3.x to PATH\u524d\u52fe\u9009\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06python3\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0c\u7136\u540e\u5728Customize installation\u4e2d\u81ea\u5b9a\u4e49\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<p>\u76f4\u63a5next\u5373\u53ef<\/p>\n<p>\u4e0b\u56fe\u4e2dAdvanced Options\u4e2d\u6ca1\u6709\u9ed8\u8ba4\u52fe\u9009\u7684\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u8fdb\u884c\u52fe\u9009\uff0c\u9ec4\u8272\u6807\u8bb0\u4e3aVS 2015\u53ca\u5176\u4ee5\u540e\u7248\u672c\u9700\u8981\u7684\uff0c\u5982\u679c\u4f60\u4ee5\u540e\u6253\u7b97\u5728VS 2015\u4e2d\u914d\u7f6epython\u73af\u5883\u8bf7\u52fe\u9009\u6b64\u9879\uff0c\u70b9\u51fbBrowse\u9009\u62e9\u5b89\u88c5\u76ee\u5f55\uff0c\u7136\u540e\u70b9\u51fbInstall\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p>\u7b49\u5f85\u5982\u4e0b\u5b89\u88c5\u8fc7\u7a0b<\/p>\n<p>\u5b89\u88c5\u6210\u529f<\/p>\n<p>\u70b9\u51fb\u5173\u95ed\uff0c\u67e5\u770bpython3\u5b89\u88c5\u60c5\u51b5\uff0c\u6309\u201cWin + R\u201d\u5feb\u6377\u952e\uff0c\u5728\u6253\u5f00\u7684\u201c\u8fd0\u884c\u201d\u5bf9\u8bdd\u6846\u4e2d\uff0c\u8f93\u5165\u201ccmd\u201d\u6309\u56de\u8f66\uff0c\u8fdb\u5165\u5982\u4e0b\u754c\u9762\uff0c\u8f93\u5165python\u67e5\u770bpython3\u5b89\u88c5\u60c5\u51b5\uff0c\u663e\u793apython3\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u5b89\u88c5\u6210\u529f\uff0c\u53ef\u4ee5\u8f93\u5165\u8bed\u53e5print(1 + 1)\u8fdb\u884c\u6d4b\u8bd5<\/p>\n<p>\u6700\u540e\u4e00\u6b65\u662f\u627e\u5230python3 IDLE\u5b89\u88c5\u4f4d\u7f6e\uff0c\u53d1\u9001\u5feb\u6377\u65b9\u5f0f\u5230\u684c\u9762\u5373\u53ef\u3002\uff08<em>\u53ef\u4ee5\u4fee\u6539\u6ce8\u518c\u8868\uff0c\u76f4\u63a5\u5728\u53f3\u952e\u6dfb\u52a0\u5feb\u6377\u65b9\u5f0f<\/em>\uff09<br \/>\n\u6253\u5f00python3.x Shell\u754c\u9762\u5c31\u53ef\u4ee5\u8fdb\u884cpython\u5f00\u53d1\u4e86<\/p>\n<h3><strong>3\u3001python2\u5b89\u88c5<\/strong><\/h3>\n<p>\u70b9\u51fbpython2\u5b89\u88c5\u5305\uff0c\u70b9\u51fb\u8fd0\u884c\uff0cnext\uff0c\u9009\u62e9\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a\u672c\u6587\u5b89\u88c5\u8def\u5f84\u4e3aC:\\python27\uff0c\u7136\u540enext<br \/>\n\u4e0b\u56fe\u9ec4\u8272\u5708\u51fa\u7684\u90e8\u5206\uff0c\u663e\u793a\u4e0d\u80fd\u591f\u6dfb\u52a0\u8def\u5f84\u5230\u7cfb\u7edf\u53d8\u91cf\uff0c\u4e0d\u80fd\u591f\u76f4\u63a5\u4f7f\u7528python\u547d\u4ee4\u6ca1\u6709\u5173\u7cfb\uff0c\u5148\u70b9\u51fbnext\u8fdb\u884c\u5b89\u88c5\uff0c\u540e\u9762\u4e13\u95e8\u89e3\u51b3\u3002<br \/>\n\u70b9\u51fbfinish\u5b8c\u6210\u5b89\u88c5\u3002<br \/>\n\u81f3\u6b64\uff0cpython2\u548cpython3\u5b89\u88c5\u5b8c\u6bd5\u3002<\/p>\n<p><strong>\u7279\u522b\u8bf4\u660e\uff1a\u6b64\u65f6\u8fd0\u884c\u201ccmd\u201d\u547d\u4ee4\u8fdb\u5165DOS\u547d\u4ee4\u63d0\u793a\u6846\uff0c\u8f93\u5165python\u4ecd\u7136\u663e\u793apython3\u7248\u672c\uff0c\u8bf7\u7ee7\u7eed\u5f80\u540e\u770b\u3002<\/strong><\/p>\n<h3><strong>4\u3001\u6dfb\u52a0python2\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/strong><\/h3>\n<p>\u6253\u5f00\uff0c\u63a7\u5236\u9762\u677f\\\u7cfb\u7edf\u548c\u5b89\u5168\\\u7cfb\u7edf\uff0c\u9009\u62e9\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\uff0c\u73af\u5883\u53d8\u91cf\uff0c\u9009\u62e9Path\uff0c\u70b9\u51fb\u7f16\u8f91\uff0c\u65b0\u5efa\uff0c\u5206\u522b\u6dfb\u52a0C:\\python27\u548cC:\\python27\\Scripts\u5230\u73af\u5883\u53d8\u91cf\u3002<br \/>\n\u6ce8\u610f\uff1apython3\u5b89\u88c5\u65f6\u53ef\u4ee5\u9009\u62e9\u81ea\u52a8\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0c\u5982\u672a\u9009\u62e9\uff0c\u65b9\u6cd5\u548cpython2\u6dfb\u52a0\u8fc7\u7a0b\u76f8\u540c\u3002<\/p>\n<h3><strong>5\u3001\u4fee\u6539python.exe\u540d\u5b57\u4e3apython2.exe\u548cpython3.exe<\/strong><\/h3>\n<p>\u627e\u5230python2\u548cpython3\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4fee\u6539<em>python2.x<\/em>\u548cpython3.x\u4e2dpython.exe\u548cpythonw.exe\u7684\u540d\u79f0\u4e3a<em>python2.exe\u3001pythonw2.exe<\/em>\u548cpython3.exe\u3001pythonw3.exe\u3002<\/p>\n<p>\uff08\u56e0\u4e3a\u672c\u673a\u9700\u8981\uff0c\u6240\u4ee5\u53ea\u4fee\u6539\u4e86python3\u7684\u6587\u4ef6\u540d\uff09<\/p>\n<p>\u7136\u540e\u5728\u8fd0\u884ccmd\u547d\u4ee4\uff0c\u8f93\u5165python\u5373\u53ef\u8fd0\u884cpython2.x\u7248\u672c<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-468\" src=\"http:\/\/www.theoldhero.com\/wp-content\/uploads\/2021\/12\/python2.png\" alt=\"\" width=\"977\" height=\"193\" \/><\/p>\n<p>\u8f93\u5165python3\u5373\u53ef\u8fd0\u884cpython3.x\u7248\u672c<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-469\" src=\"http:\/\/www.theoldhero.com\/wp-content\/uploads\/2021\/12\/python3.png\" alt=\"\" width=\"974\" height=\"275\" \/><\/p>\n<p>\u81f3\u6b64\uff0cpython2\u548cpython3 \u5b89\u88c5\u5b8c\u6bd5\u3002<\/p>\n<h3><strong>6\u3001pip2 \u548c pip3\u8bbe\u7f6e<\/strong><\/h3>\n<p>Python \u5b89\u88c5\u5305\u9700\u8981\u7528\u5230\u5305\u7ba1\u7406\u5de5\u5177pip\uff0c\u4f46\u662f\u5f53\u540c\u65f6\u5b89\u88c5python2\u548cpython3\u7684\u65f6\u5019\uff0cpip\u53ea\u662f\u5176\u4e2d\u4e00\u4e2a\u7248\u672c\uff0c\u4ee5\u4e0b\u5c06\u63d0\u4f9b\u4e00\u4e2a\u4fee\u6539\u65b9\u5f0f\uff0c\u5373\u91cd\u65b0\u5b89\u88c5\u4e24\u4e2a\u7248\u672c\u7684pip\uff0c\u4f7f\u5f97\u4e24\u4e2apython\u7248\u672c\u7684pip\u80fd\u591f\u5171\u5b58\u3002<\/p>\n<p>\u5728DOS\u547d\u4ee4\u6846\u8f93\u5165\u547d\u4ee4\uff0cpython2-m pip install &#8211;upgrade pip &#8211;force-reinstall\uff0c\u663e\u793a\u91cd\u65b0\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p>\u5728DOS\u547d\u4ee4\u6846\u8f93\u5165\u547d\u4ee4\uff0cpython3-m pip install &#8211;upgrade pip &#8211;force-reinstall\uff0c\u663e\u793a\u91cd\u65b0\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u901a\u8fc7pip2 -V \u548c pip3-V \u67e5\u770b\u4e24\u4e2a\u7248\u672c\u7684pip\u4fe1\u606f\uff0c\u4ee5\u540e\u53ea\u9700\u8fd0\u884cpip2install XXX\u548cpip3 install XXX\u5373\u53ef\u5b89\u88c5\u5404\u81ea\u7684python\u5305\u3002<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-467\" src=\"http:\/\/www.theoldhero.com\/wp-content\/uploads\/2021\/12\/PIP\u5bf9\u6bd4.png\" alt=\"\" width=\"552\" height=\"96\" \/><\/p>\n<p>\u81f3\u6b64\uff0cpip2\u548cpip3 \u4fee\u6539\u6210\u529f\u3002<\/p>\n<h3><strong>7\u3001\u5728PyCharm\u4e2d\u5207\u6362<\/strong><\/h3>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fPyCharm\u7f16\u5199Python\uff0c\u5f53\u9700\u8981\u5207\u6362Python\u7248\u672c\u65f6\uff0c\u53ea\u9700\u8981\u5728\u8bbe\u7f6e\u4e2d\u641c\u7d22\u201cProject Interpreter\u201d\uff0c\u7136\u540e\u8fdb\u884c\u5207\u6362\u5373\u53ef\uff0c\u540c\u65f6\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u5b89\u88c5\u5230\u8be5\u7248\u672c\u4e2d\u7684\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e0b\u8f7dpython3\u548cpython2 \u8fdb\u5165python\u5b98\u7f51\uff0c\u94fe\u63a5https:\/\/www.python.org <a href=\"http:\/\/www.theoldhero.com\/?p=466\" rel=\"nofollow\"><span class=\"sr-only\">Read more about \u5982\u4f55\u8bbe\u7f6ePython2.x\u4e0e3.x\u5171\u5b58<\/span>[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13],"tags":[],"_links":{"self":[{"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/posts\/466"}],"collection":[{"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=466"}],"version-history":[{"count":8,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":477,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions\/477"}],"wp:attachment":[{"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.theoldhero.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}