{"id":1160146,"date":"2025-01-13T19:01:34","date_gmt":"2025-01-13T11:01:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1160146.html"},"modified":"2025-01-13T19:01:36","modified_gmt":"2025-01-13T11:01:36","slug":"%e5%a6%82%e4%bd%95%e4%b8%8b%e8%bd%bd%e4%b9%8b%e5%89%8d%e7%89%88%e6%9c%ac%e7%9a%84python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1160146.html","title":{"rendered":"\u5982\u4f55\u4e0b\u8f7d\u4e4b\u524d\u7248\u672c\u7684python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25201654\/74d2943e-27a8-415a-a678-c4ac773007dc.webp\" alt=\"\u5982\u4f55\u4e0b\u8f7d\u4e4b\u524d\u7248\u672c\u7684python\" \/><\/p>\n<p><p> <strong>\u4e0b\u8f7d\u4e4b\u524d\u7248\u672c\u7684Python\u6709\u51e0\u79cd\u65b9\u6cd5<\/strong>\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6216\u8005\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7d\u3002<strong>\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d<\/strong>\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u6240\u6709\u7248\u672c\u7684Python\uff0c\u5e76\u4e14\u786e\u4fdd\u4e86\u4e0b\u8f7d\u7684\u5b89\u5168\u6027\u3002\u4f60\u53ea\u9700\u8bbf\u95eePython\u7684\u5b98\u65b9\u5386\u53f2\u7248\u672c\u9875\u9762\uff0c\u9009\u62e9\u4f60\u9700\u8981\u7684\u7248\u672c\u5e76\u4e0b\u8f7d\u5373\u53ef\u3002<strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/strong>\u5982Anaconda\u6216Homebrew\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u8fd9\u5bf9\u4e8e\u9700\u8981\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u7684\u7528\u6237\u975e\u5e38\u6709\u7528\u3002<strong>\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7d<\/strong>\u53ef\u4ee5\u627e\u5230\u4e00\u4e9b\u975e\u5b98\u65b9\u7684\u5386\u53f2\u7248\u672c\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<p><p>\u8ba9\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u4e00\u4e0b\u5982\u4f55\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u4e4b\u524d\u7684\u7248\u672c\u3002\u8fd9\u662f\u4e00\u4e2a\u5b89\u5168\u4e14\u53ef\u9760\u7684\u65b9\u6cd5\u3002\u9996\u5148\uff0c\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u7136\u540e\u5bfc\u822a\u5230Downloads\u90e8\u5206\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a&quot;View the full list of downloads&quot;\u7684\u94fe\u63a5\uff0c\u70b9\u51fb\u5b83\u540e\u4f1a\u8df3\u8f6c\u5230Python\u7684\u5386\u53f2\u7248\u672c\u9875\u9762\u3002\u5728\u8fd9\u4e2a\u9875\u9762\uff0c\u4f60\u53ef\u4ee5\u6d4f\u89c8\u6240\u6709\u4e4b\u524d\u53d1\u5e03\u7684Python\u7248\u672c\u3002\u9009\u62e9\u4f60\u9700\u8981\u7684\u7248\u672c\u5e76\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u8fdb\u884c\u5b89\u88c5\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d<\/h3>\n<\/p>\n<p><p>\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5386\u53f2\u7248\u672c\u662f\u6700\u7b80\u5355\u4e5f\u662f\u6700\u53ef\u9760\u7684\u65b9\u6cd5\u3002Python\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u4ece\u6700\u65e9\u7248\u672c\u5230\u6700\u65b0\u7248\u672c\u7684\u4e0b\u8f7d\u94fe\u63a5\uff0c\u8fd9\u4e9b\u94fe\u63a5\u7ecf\u8fc7\u4e86\u5b98\u65b9\u7684\u9a8c\u8bc1\uff0c\u786e\u4fdd\u4e86\u4e0b\u8f7d\u7684\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9<\/h4>\n<\/p>\n<p><p>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8f93\u5165\u7f51\u5740\uff1a<a href=\"https:\/\/www.python.org\/%EF%BC%8C%E8%BF%9B%E5%85%A5Python%E5%AE%98%E6%96%B9%E7%BD%91%E7%AB%99%E3%80%82%E5%9C%A8%E4%B8%BB%E9%A1%B5%E4%B8%8A%EF%BC%8C%E4%BD%A0%E5%8F%AF%E4%BB%A5%E7%9C%8B%E5%88%B0%E5%AF%BC%E8%88%AA%E6%A0%8F%E3%80%82\">https:\/\/www.python.org\/\uff0c\u8fdb\u5165Python\u5b98\u65b9\u7f51\u7ad9\u3002\u5728\u4e3b\u9875\u4e0a\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5bfc\u822a\u680f\u3002<\/a><\/p>\n<\/p>\n<p><h4>2\u3001\u5bfc\u822a\u5230Downloads\u9875\u9762<\/h4>\n<\/p>\n<p><p>\u5728\u5bfc\u822a\u680f\u4e2d\u627e\u5230&quot;Downloads&quot;\u9009\u9879\uff0c\u5e76\u70b9\u51fb\u5b83\u3002\u5728\u4e0b\u8f7d\u9875\u9762\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u201cLooking for a specific release?\u201d\u7684\u94fe\u63a5\u3002\u70b9\u51fb\u8fd9\u4e2a\u94fe\u63a5\uff0c\u4f60\u5c06\u88ab\u5e26\u5230Python\u7684\u6240\u6709\u5386\u53f2\u7248\u672c\u9875\u9762\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u9009\u62e9\u6240\u9700\u7248\u672c<\/h4>\n<\/p>\n<p><p>\u5728\u5386\u53f2\u7248\u672c\u9875\u9762\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u957f\u5217\u8868\uff0c\u5305\u542b\u4e86\u6240\u6709\u53d1\u5e03\u8fc7\u7684Python\u7248\u672c\u3002\u6bcf\u4e2a\u7248\u672c\u90fd\u6709\u5bf9\u5e94\u7684\u4e0b\u8f7d\u94fe\u63a5\u548c\u53d1\u5e03\u8bf4\u660e\u3002\u9009\u62e9\u4f60\u9700\u8981\u7684\u7248\u672c\uff0c\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u7684\u6307\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u901a\u5e38\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u70b9\u51fb\u51e0\u4e0b\u9f20\u6807\u5373\u53ef\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u4e0b\u8f7d\u7279\u5b9a\u7248\u672c\u7684Python\u662f\u53e6\u4e00\u79cd\u65b9\u6cd5\u3002\u5305\u7ba1\u7406\u5668\u5982Anaconda\u3001Homebrew\u7b49\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Anaconda<\/h4>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u79d1\u5b66\u8ba1\u7b97\u5e73\u53f0\uff0c\u5305\u542b\u4e86Python\u53ca\u5176\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u5305\u3002\u4f7f\u7528Anaconda\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Anaconda<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u8bbf\u95eeAnaconda\u5b98\u7f51\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00Anaconda Prompt\u3002<\/p>\n<\/p>\n<p><h5>\u521b\u5efa\u865a\u62df\u73af\u5883<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u6307\u5b9aPython\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create -n myenv python=3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u5b89\u88c5Python 3.7\u3002<\/p>\n<\/p>\n<p><h5>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u4e2a\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528\u6307\u5b9a\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528Homebrew<\/h4>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u4e00\u4e2a\u6d41\u884c\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u5305\u62ecPython\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Homebrew<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Homebrew\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python@3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew link --force --overwrite python@3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7d<\/h3>\n<\/p>\n<p><p>\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7dPython\u5386\u53f2\u7248\u672c\u662f\u4e00\u79cd\u5907\u7528\u65b9\u6cd5\u3002\u8fd9\u4e9b\u5b58\u50a8\u5e93\u53ef\u80fd\u5305\u542b\u4e00\u4e9b\u5b98\u65b9\u672a\u63d0\u4f9b\u7684\u7248\u672c\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u4e0b\u8f7d\u7684\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bbf\u95ee\u53ef\u4fe1\u8d56\u7684\u5b58\u50a8\u5e93<\/h4>\n<\/p>\n<p><p>\u4e00\u4e9b\u53ef\u4fe1\u8d56\u7684\u5f00\u6e90\u9879\u76ee\u548c\u7ec4\u7ec7\u4f1a\u7ef4\u62a4\u81ea\u5df1\u7684Python\u7248\u672c\u5b58\u50a8\u5e93\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u8bbf\u95eeGitHub\u4e0a\u7684\u4e00\u4e9b\u9879\u76ee\uff0c\u8fd9\u4e9b\u9879\u76ee\u53ef\u80fd\u4f1a\u63d0\u4f9b\u67d0\u4e9b\u7279\u5b9a\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u9009\u62e9\u548c\u4e0b\u8f7d<\/h4>\n<\/p>\n<p><p>\u6d4f\u89c8\u5b58\u50a8\u5e93\uff0c\u627e\u5230\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff0c\u5e76\u4e0b\u8f7d\u5bf9\u5e94\u7684\u5b89\u88c5\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5b89\u88c5\u548c\u914d\u7f6e<\/h4>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6309\u7167\u5b89\u88c5\u6587\u4ef6\u7684\u8bf4\u660e\u8fdb\u884c\u5b89\u88c5\u548c\u914d\u7f6e\u3002\u8fd9\u4e9b\u5b89\u88c5\u6587\u4ef6\u53ef\u80fd\u4e0d\u4f1a\u50cf\u5b98\u65b9\u5b89\u88c5\u7a0b\u5e8f\u90a3\u6837\u76f4\u89c2\uff0c\u6240\u4ee5\u4f60\u9700\u8981\u4ed4\u7ec6\u9605\u8bfb\u8bf4\u660e\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528Pyenv\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/h3>\n<\/p>\n<p><p>Pyenv\u662f\u4e00\u6b3e\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8f7b\u677e\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u5b83\u4e0d\u4ec5\u53ef\u4ee5\u5b89\u88c5\u548c\u5207\u6362\u4e0d\u540c\u7684Python\u7248\u672c\uff0c\u8fd8\u53ef\u4ee5\u521b\u5efa\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5Pyenv<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5Pyenv\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728macOS\u6216Linux\u4e0a\u5b89\u88c5Pyenv\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6309\u7167\u63d0\u793a\u6dfb\u52a0\u4ee5\u4e0b\u51e0\u884c\u5230\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff08\u5982<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\uff09\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;$HOME\/.pyenv\/bin:$PATH&quot;<\/p>\n<p>eval &quot;$(pyenv init --path)&quot;<\/p>\n<p>eval &quot;$(pyenv init -)&quot;<\/p>\n<p>eval &quot;$(pyenv virtualenv-init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709\u53ef\u7528\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install --list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u627e\u5230\u4f60\u9700\u8981\u7684\u7248\u672c\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5207\u6362Python\u7248\u672c<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5c06Python 3.7.9\u8bbe\u7f6e\u4e3a\u5168\u5c40\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u5728\u5f53\u524d\u9879\u76ee\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv local 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528Pyenv\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv virtualenv 3.7.9 myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528Docker\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684Python<\/h3>\n<\/p>\n<p><p>Docker\u662f\u4e00\u79cd\u5bb9\u5668\u6280\u672f\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5728\u9694\u79bb\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684Python\u3002\u8fd9\u5bf9\u4e8e\u6d4b\u8bd5\u548c\u5f00\u53d1\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u4f60\u53ef\u4ee5\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u5728\u4e0d\u540c\u7684Python\u7248\u672c\u4e2d\u884c\u4e3a\u4e00\u81f4\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5Docker<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5Docker\u3002\u4f60\u53ef\u4ee5\u4eceDocker\u5b98\u7f51\uff08<a href=\"https:\/\/www.docker.com\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85Docker\">https:\/\/www.docker.com\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5Docker<\/a> Desktop\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u62c9\u53d6\u6307\u5b9a\u7248\u672c\u7684Python\u955c\u50cf<\/h4>\n<\/p>\n<p><p>Docker Hub\u4e0a\u6709\u8bb8\u591a\u5b98\u65b9\u548c\u975e\u5b98\u65b9\u7684Python\u955c\u50cf\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u62c9\u53d6\u6307\u5b9a\u7248\u672c\u7684Python\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker pull python:3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u8fd0\u884cPython\u5bb9\u5668<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u4e00\u4e2a\u5305\u542b\u6307\u5b9a\u7248\u672cPython\u7684\u5bb9\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker run -it python:3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u542f\u52a8\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u5bb9\u5668\uff0c\u5e76\u8fdb\u5165Python 3.7\u7684shell\u3002\u4f60\u53ef\u4ee5\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u4f60\u7684\u4ee3\u7801\uff0c\u5e76\u786e\u4fdd\u5b83\u5728\u8fd9\u4e2a\u7279\u5b9a\u7248\u672c\u7684Python\u4e2d\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u521b\u5efaDockerfile<\/h4>\n<\/p>\n<p><p>\u4f60\u8fd8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aDockerfile\uff0c\u4ee5\u4fbf\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u7279\u5b9a\u7248\u672cPython\u7684\u81ea\u5b9a\u4e49\u73af\u5883\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>Dockerfile<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-dockerfile\">FROM python:3.7<\/p>\n<p>WORKDIR \/app<\/p>\n<p>COPY . \/app<\/p>\n<p>RUN pip install -r requirements.txt<\/p>\n<p>CMD [&quot;python&quot;, &quot;your_script.py&quot;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6784\u5efa\u548c\u8fd0\u884c\u4f60\u7684Docker\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker build -t my-python-app .<\/p>\n<p>docker run my-python-app<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u5728Windows\u4e0a\u4f7f\u7528Python\u7684\u5386\u53f2\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5728Windows\u4e0a\u4e0b\u8f7d\u548c\u5b89\u88c5Python\u7684\u5386\u53f2\u7248\u672c\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4e0b\u8f7d\u5386\u53f2\u7248\u672c<\/h4>\n<\/p>\n<p><p>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u5bfc\u822a\u5230Downloads\u9875\u9762\uff0c\u7136\u540e\u70b9\u51fb\u201cView the full list of downloads\u201d\u94fe\u63a5\u3002\u9009\u62e9\u4f60\u9700\u8981\u7684\u5386\u53f2\u7248\u672c\uff0c\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\uff0c\u9009\u62e9\u9002\u5408Windows\u7684\u5b89\u88c5\u6587\u4ef6\uff08\u901a\u5e38\u662f<code>.exe<\/code>\u6587\u4ef6\uff09\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5b89\u88c5Python<\/h4>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u6587\u4ef6\uff0c\u542f\u52a8\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u754c\u9762\u4e2d\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u201cAdd Python to PATH\u201d\uff0c\u8fd9\u5c06\u81ea\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u65b9\u4fbf\u4f60\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5728\u5b89\u88c5\u65f6\u6ca1\u6709\u9009\u62e9\u201cAdd Python to PATH\u201d\uff0c\u4f60\u9700\u8981\u624b\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\uff0c\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\uff0c\u7136\u540e\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4f8b\u5982<code>C:\\Python37<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5728Linux\u4e0a\u4f7f\u7528Python\u7684\u5386\u53f2\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5728Linux\u4e0a\u4e0b\u8f7d\u548c\u5b89\u88c5Python\u7684\u5386\u53f2\u7248\u672c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6216\u8005\u624b\u52a8\u7f16\u8bd1\u6e90\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/h4>\n<\/p>\n<p><p>\u8bb8\u591aLinux\u53d1\u884c\u7248\u63d0\u4f9b\u4e86\u5305\u7ba1\u7406\u5668\uff0c\u5982apt\u3001yum\u7b49\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><h5>\u4f7f\u7528apt\uff08Debian\/Ubuntu\uff09<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt install python3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u4f7f\u7528yum\uff08CentOS\/RHEL\uff09<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u542f\u7528EPEL\u5b58\u50a8\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install epel-release<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python37<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u624b\u52a8\u7f16\u8bd1\u6e90\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u5305\u7ba1\u7406\u5668\u4e2d\u6ca1\u6709\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u7f16\u8bd1\u6e90\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h5>\u4e0b\u8f7d\u6e90\u4ee3\u7801<\/h5>\n<\/p>\n<p><p>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u5bfc\u822a\u5230Downloads\u9875\u9762\uff0c\u7136\u540e\u70b9\u51fb\u201cView the full list of downloads\u201d\u94fe\u63a5\u3002\u9009\u62e9\u4f60\u9700\u8981\u7684\u5386\u53f2\u7248\u672c\uff0c\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\uff0c\u4e0b\u8f7d\u6e90\u4ee3\u7801\u538b\u7f29\u5305\uff08\u901a\u5e38\u662f<code>.tgz<\/code>\u6587\u4ef6\uff09\u3002<\/p>\n<\/p>\n<p><h5>\u89e3\u538b\u7f29\u6e90\u4ee3\u7801<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u89e3\u538b\u7f29\u6e90\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">tar -xzf Python-3.7.9.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u7f16\u8bd1\u548c\u5b89\u88c5<\/h5>\n<\/p>\n<p><p>\u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd Python-3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u548c\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/configure<\/p>\n<p>make<\/p>\n<p>sudo make install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3.7 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662f\u4e00\u79cd\u5728Python\u9879\u76ee\u4e2d\u9694\u79bb\u4f9d\u8d56\u7684\u65b9\u5f0f\uff0c\u786e\u4fdd\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u4e0d\u4f1a\u76f8\u4e92\u5e72\u6270\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3.7 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u4f7f\u7528Python 3.7\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5b89\u88c5\u4f9d\u8d56<\/h4>\n<\/p>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4\u3001\u9000\u51fa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5f53\u4f60\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u5e76\u5728\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u5207\u6362\u3002<\/p>\n<\/p>\n<p><h4>1\u3001Pyenv<\/h4>\n<\/p>\n<p><p>Pyenv\u662f\u4e00\u6b3e\u5f3a\u5927\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8f7b\u677e\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Pyenv<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Pyenv\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6309\u7167\u63d0\u793a\u6dfb\u52a0\u4ee5\u4e0b\u51e0\u884c\u5230\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff08\u5982<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\uff09\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;$HOME\/.pyenv\/bin:$PATH&quot;<\/p>\n<p>eval &quot;$(pyenv init --path)&quot;<\/p>\n<p>eval &quot;$(pyenv init -)&quot;<\/p>\n<p>eval &quot;$(pyenv virtualenv-init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709\u53ef\u7528\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install --list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u627e\u5230\u4f60\u9700\u8981\u7684\u7248\u672c\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5207\u6362Python\u7248\u672c<\/h5>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5c06Python 3.7.9\u8bbe\u7f6e\u4e3a\u5168\u5c40\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u5728\u5f53\u524d\u9879\u76ee\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv local 3.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001Conda<\/h4>\n<\/p>\n<p><p>Conda\u662fAnaconda\u7684\u5305\u7ba1\u7406\u5668\u548c\u73af\u5883\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u548c\u5305\u4f9d\u8d56\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Conda<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u8bbf\u95eeAnaconda\u5b98\u7f51\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00Anaconda Prompt\u3002<\/p>\n<\/p>\n<p><h5>\u521b\u5efa\u865a\u62df\u73af\u5883<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u6307\u5b9aPython\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create -n myenv python=3.7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u5b89\u88c5Python 3.7\u3002<\/p>\n<\/p>\n<p><h5>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h5>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u4e2a\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528\u6307\u5b9a\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5\u4f9d\u8d56<\/h5>\n<\/p>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528conda\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install -y numpy pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u9000\u51fa\u865a\u62df\u73af\u5883<\/h5>\n<\/p>\n<p><p>\u5f53\u4f60\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u4e0b\u8f7d\u548c\u5b89\u88c5\u4e4b\u524d\u7248\u672c\u7684Python\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u4f60\u7684\u5177\u4f53\u9700\u6c42\u548c\u64cd\u4f5c\u7cfb\u7edf\u3002\u65e0\u8bba\u662f\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3001\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7d\u3001\u4f7f\u7528Pyenv\u3001Docker\uff0c\u8fd8\u662f\u5728Windows\u548cLinux\u4e0a\u624b\u52a8\u5b89\u88c5\uff0c\u4e86\u89e3\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7ba1\u7406Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p><strong>\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u662f\u6700\u7b80\u5355\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5<\/strong>\uff0c\u800c<strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5982Anaconda\u548cHomebrew<\/strong>\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<strong>Pyenv\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/strong>\uff0c\u9002\u5408\u9700\u8981\u9891\u7e41\u5207\u6362Python\u7248\u672c\u7684\u5f00\u53d1\u8005\u3002<strong>Docker\u53ef\u4ee5\u5728\u9694\u79bb\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684Python<\/strong>\uff0c\u786e\u4fdd\u4ee3\u7801\u5728\u4e0d\u540c\u7248\u672c\u4e2d\u7684\u4e00\u81f4\u6027\u3002<strong>\u865a\u62df\u73af\u5883\u53ef\u4ee5\u9694\u79bb\u9879\u76ee\u4f9d\u8d56<\/strong>\uff0c\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u3002\u4e86\u89e3\u5e76\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u7684\u5f00\u53d1\u73af\u5883\u4e2d\u7075\u6d3b\u5730\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u627e\u5230\u6211\u9700\u8981\u7684Python\u65e7\u7248\u672c\uff1f<\/strong><br \/>\u8981\u627e\u5230\u9700\u8981\u7684Python\u65e7\u7248\u672c\uff0c\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u5e76\u5bfc\u822a\u5230\u4e0b\u8f7d\u9875\u9762\u3002\u5728\u4e0b\u8f7d\u9875\u9762\u4e2d\uff0c\u60a8\u4f1a\u770b\u5230\u201c\u6240\u6709\u7248\u672c\u201d\u94fe\u63a5\uff0c\u70b9\u51fb\u540e\u53ef\u4ee5\u6d4f\u89c8\u5230\u6240\u6709\u53ef\u7528\u7684Python\u7248\u672c\uff0c\u9009\u62e9\u60a8\u9700\u8981\u7684\u7279\u5b9a\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n<p><strong>\u65e7\u7248\u672c\u7684Python\u662f\u5426\u4ecd\u7136\u5b89\u5168\u53ef\u7528\uff1f<\/strong><br \/>\u867d\u7136\u65e7\u7248\u672c\u7684Python\u53ef\u4ee5\u4f7f\u7528\uff0c\u4f46\u5b89\u5168\u6027\u548c\u6027\u80fd\u53ef\u80fd\u4e0d\u5982\u6700\u65b0\u7248\u672c\u3002\u8bb8\u591a\u65e7\u7248\u672c\u53ef\u80fd\u5df2\u7ecf\u505c\u6b62\u652f\u6301\uff0c\u610f\u5473\u7740\u4e0d\u518d\u63d0\u4f9b\u5b89\u5168\u66f4\u65b0\u6216\u4fee\u590d\u7a0b\u5e8f\u3002\u5982\u679c\u5fc5\u987b\u4f7f\u7528\u65e7\u7248\u672c\uff0c\u8bf7\u786e\u4fdd\u5b83\u9002\u7528\u4e8e\u60a8\u7684\u7279\u5b9a\u9879\u76ee\uff0c\u5e76\u8bc4\u4f30\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u6211\u7684\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e0b\u8f7d\u7684\u65e7\u7248\u672cPython\uff1f<\/strong><br \/>\u5b89\u88c5\u65e7\u7248\u672c\u7684Python\u4e0e\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684\u6b65\u9aa4\u57fa\u672c\u76f8\u540c\u3002\u4e0b\u8f7d\u76f8\u5e94\u7684\u5b89\u88c5\u5305\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u64cd\u4f5c\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u9009\u62e9\u6dfb\u52a0Python\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u8f7b\u677e\u8bbf\u95ee\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u524d\u5378\u8f7d\u73b0\u6709\u7248\u672c\uff0c\u4ee5\u907f\u514d\u51b2\u7a81\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e0b\u8f7d\u4e4b\u524d\u7248\u672c\u7684Python\u6709\u51e0\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6216\u8005\u4ece\u5176\u4ed6\u5b58\u50a8\u5e93\u4e0b\u8f7d\u3002\u4ecePy [&hellip;]","protected":false},"author":3,"featured_media":1160155,"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\/1160146"}],"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=1160146"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160146\/revisions"}],"predecessor-version":[{"id":1160156,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160146\/revisions\/1160156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1160155"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1160146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1160146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1160146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}