{"id":922412,"date":"2024-12-26T14:30:57","date_gmt":"2024-12-26T06:30:57","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/922412.html"},"modified":"2024-12-26T14:31:00","modified_gmt":"2024-12-26T06:31:00","slug":"windows%e5%a6%82%e4%bd%95%e5%8d%87%e7%ba%a7python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/922412.html","title":{"rendered":"windows\u5982\u4f55\u5347\u7ea7python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210932\/876e00a1-2820-4753-8991-59327761ba28.webp\" alt=\"windows\u5982\u4f55\u5347\u7ea7python\" \/><\/p>\n<p><p> <strong>\u8981\u5728Windows\u4e0a\u5347\u7ea7Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5982Chocolatey\u3001\u6216\u8005\u4f7f\u7528Anaconda\u8fdb\u884c\u7ba1\u7406\u3002\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u80fd\u5e2e\u52a9\u60a8\u987a\u5229\u5347\u7ea7Python\u7248\u672c\u3002<\/strong>\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u6bcf\u79cd\u65b9\u6cd5\u7684\u5177\u4f53\u6b65\u9aa4\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u548c\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9<\/strong><br \/>\u9996\u5148\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E9%A6%96%E9%A1%B5%E7%9A%84%E2%80%9CDownloads%E2%80%9D%E9%83%A8%E5%88%86%EF%BC%8C%E6%82%A8%E9%80%9A%E5%B8%B8%E5%8F%AF%E4%BB%A5%E7%9C%8B%E5%88%B0%E6%8E%A8%E8%8D%90%E7%9A%84%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u9996\u9875\u7684\u201cDownloads\u201d\u90e8\u5206\uff0c\u60a8\u901a\u5e38\u53ef\u4ee5\u770b\u5230\u63a8\u8350\u7684\u6700\u65b0\u7248\u672c\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7d\u6700\u65b0\u7248\u672c<\/strong><br \/>\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\uff0c\u9009\u62e9\u9002\u5408\u60a8\u7cfb\u7edf\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u901a\u5e38\uff0c\u7f51\u7ad9\u4f1a\u81ea\u52a8\u68c0\u6d4b\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u5e76\u63a8\u8350\u76f8\u5e94\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/strong><br \/>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u5411\u5bfc\u4e2d\uff0c\u5efa\u8bae\u9009\u4e2d\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u8f7b\u677e\u8bbf\u95eePython\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5347\u7ea7\u9009\u9879<\/strong><br \/>\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u68c0\u6d4b\u73b0\u6709\u7684Python\u7248\u672c\uff0c\u5e76\u63d0\u4f9b\u5347\u7ea7\u9009\u9879\u3002\u786e\u8ba4\u540e\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u66ff\u6362\u65e7\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python --version<\/code>\u4ee5\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177Chocolatey<\/p>\n<\/p>\n<p><p>Chocolatey\u662f\u4e00\u79cdWindows\u4e0b\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u7b80\u5316Python\u7684\u5b89\u88c5\u548c\u5347\u7ea7\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Chocolatey<\/strong><br \/>\u5982\u679c\u5c1a\u672a\u5b89\u88c5Chocolatey\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884cPowerShell\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">Set-ExecutionPolicy Bypass -Scope Process -Force; `<\/p>\n<p>[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `<\/p>\n<p>iex ((New-Object System.Net.WebClient).DownloadString(&#39;https:\/\/chocolatey.org\/install.ps1&#39;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7Python<\/strong><br \/>\u4f7f\u7528Chocolatey\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5347\u7ea7Python\u3002\u6253\u5f00\u7ba1\u7406\u5458\u6743\u9650\u7684\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">choco upgrade python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u7684\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\u540c\u6837\u5730\uff0c\u901a\u8fc7\u547d\u4ee4<code>python --version<\/code>\u6765\u9a8c\u8bc1\u5347\u7ea7\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528Anaconda\u8fdb\u884c\u7ba1\u7406<\/p>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u4f7f\u7528Anaconda\u6765\u7ba1\u7406Python\u73af\u5883\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00Anaconda Prompt<\/strong><br \/>\u901a\u8fc7\u201c\u5f00\u59cb\u83dc\u5355\u201d\u627e\u5230Anaconda Prompt\u5e76\u6253\u5f00\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0Conda<\/strong><br \/>\u5728\u5347\u7ea7Python\u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u66f4\u65b0Conda\u81ea\u8eab\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">conda update conda<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7Python<\/strong><br \/>\u4f7f\u7528Conda\u6765\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">conda install python=3.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>3.x<\/code>\u662f\u60a8\u5e0c\u671b\u5347\u7ea7\u5230\u7684\u76ee\u6807\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\u518d\u6b21\u901a\u8fc7<code>python --version<\/code>\u547d\u4ee4\u786e\u8ba4\u5347\u7ea7\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5907\u4efd\u91cd\u8981\u6587\u4ef6<\/strong><br \/>\u5728\u5347\u7ea7\u4e4b\u524d\uff0c\u786e\u4fdd\u5907\u4efd\u6240\u6709\u91cd\u8981\u7684Python\u6587\u4ef6\u548c\u9879\u76ee\uff0c\u4ee5\u9632\u5347\u7ea7\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u4e0d\u517c\u5bb9\u6216\u5176\u4ed6\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u517c\u5bb9\u6027<\/strong><br \/>\u786e\u4fdd\u60a8\u7684\u9879\u76ee\u548c\u6240\u4f7f\u7528\u7684\u5e93\u4e0e\u65b0\u7248\u672c\u7684Python\u517c\u5bb9\u3002\u6709\u4e9b\u5e93\u53ef\u80fd\u9700\u8981\u66f4\u65b0\u4ee5\u652f\u6301\u65b0\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/strong><br \/>\u5982\u679c\u9700\u8981\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6216\u5de5\u5177\u5982pyenv-win\u6765\u7ba1\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728Windows\u7cfb\u7edf\u4e2d\u987a\u5229\u5347\u7ea7Python\uff0c\u786e\u4fdd\u60a8\u7684\u5f00\u53d1\u73af\u5883\u4fdd\u6301\u6700\u65b0\u548c\u6700\u4f73\u72b6\u6001\u3002\u8fd9\u4e0d\u4ec5\u80fd\u63d0\u9ad8\u4ee3\u7801\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\uff0c\u8fd8\u80fd\u8ba9\u60a8\u4f7f\u7528\u5230Python\u6700\u65b0\u7684\u7279\u6027\u548c\u529f\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u60a8\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u60a8\u5f53\u524d\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fPython 3\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528<code>python3 --version<\/code>\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5347\u7ea7Python\u65f6\u9700\u8981\u5907\u4efd\u6211\u7684\u9879\u76ee\u5417\uff1f<\/strong><br \/>\u5728\u5347\u7ea7Python\u4e4b\u524d\uff0c\u5efa\u8bae\u60a8\u5907\u4efd\u6240\u6709\u91cd\u8981\u7684\u9879\u76ee\u548c\u865a\u62df\u73af\u5883\u3002\u8fd9\u53ef\u4ee5\u907f\u514d\u56e0\u7248\u672c\u4e0d\u517c\u5bb9\u800c\u5bfc\u81f4\u7684\u6f5c\u5728\u95ee\u9898\u3002\u4f7f\u7528\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff08\u5982Git\uff09\u7ba1\u7406\u4ee3\u7801\u4e5f\u662f\u4e00\u4e2a\u597d\u4e3b\u610f\uff0c\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5728\u5347\u7ea7\u540e\u53ef\u4ee5\u6062\u590d\u5230\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p>\n<p><strong>\u5728Windows\u4e0a\u5982\u4f55\u5b89\u5168\u5730\u5378\u8f7d\u65e7\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u8981\u5b89\u5168\u5378\u8f7d\u65e7\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u63a7\u5236\u9762\u677f\u201d\u4e2d\u7684\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u627e\u5230Python\uff0c\u9009\u62e9\u5b83\u5e76\u70b9\u51fb\u201c\u5378\u8f7d\u201d\u3002\u5728\u5378\u8f7d\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u5907\u4efd\u4e86\u6240\u6709\u9879\u76ee\u548c\u76f8\u5173\u73af\u5883\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u6709\u4e0ePython\u76f8\u5173\u7684\u4f9d\u8d56\u9879\u9700\u8981\u5355\u72ec\u5904\u7406\u3002<\/p>\n<p><strong>\u5347\u7ea7Python\u540e\u5982\u4f55\u5904\u7406\u65e7\u7684\u4f9d\u8d56\u5e93\uff1f<\/strong><br \/>\u5347\u7ea7Python\u53ef\u80fd\u5bfc\u81f4\u67d0\u4e9b\u4f9d\u8d56\u5e93\u4e0d\u517c\u5bb9\u3002\u5efa\u8bae\u5728\u65b0\u7248\u672c\u7684Python\u73af\u5883\u4e2d\u91cd\u65b0\u5b89\u88c5\u6240\u6709\u5fc5\u8981\u7684\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528<code>pip freeze &gt; requirements.txt<\/code>\u547d\u4ee4\u5bfc\u51fa\u5f53\u524d\u73af\u5883\u7684\u4f9d\u8d56\u5217\u8868\uff0c\u7136\u540e\u5728\u65b0\u73af\u5883\u4e2d\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u6765\u5b89\u88c5\u4f9d\u8d56\u3002<\/p>\n<p><strong>\u5728Windows\u4e0a\uff0c\u5982\u4f55\u786e\u4fddPython\u7684\u73af\u5883\u53d8\u91cf\u6b63\u786e\u914d\u7f6e\uff1f<\/strong><br \/>\u5728\u5b89\u88c5\u6216\u5347\u7ea7Python\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u201c\u5c06Python\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u201d\u9009\u9879\u3002\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\uff1a\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u8fdb\u5165\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u4e2d\u786e\u8ba4<code>PATH<\/code>\u53d8\u91cf\u5305\u542b\u4e86Python\u548cScripts\u76ee\u5f55\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Windows\u4e0a\u5347\u7ea7Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5982Choco [&hellip;]","protected":false},"author":3,"featured_media":922415,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922412"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=922412"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922412\/revisions"}],"predecessor-version":[{"id":922416,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922412\/revisions\/922416"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/922415"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=922412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=922412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=922412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}