{"id":996164,"date":"2024-12-27T09:11:05","date_gmt":"2024-12-27T01:11:05","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/996164.html"},"modified":"2024-12-27T09:11:08","modified_gmt":"2024-12-27T01:11:08","slug":"%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85%e5%92%8c%e9%85%8d%e7%bd%aepython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/996164.html","title":{"rendered":"\u5982\u4f55\u5b89\u88c5\u548c\u914d\u7f6epython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25072511\/0c11a12a-ee74-4e2f-89e8-509ec5829f02.webp\" alt=\"\u5982\u4f55\u5b89\u88c5\u548c\u914d\u7f6epython\" \/><\/p>\n<p><p> <strong>\u5b89\u88c5\u548c\u914d\u7f6ePython\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4e0b\u8f7dPython\u5b89\u88c5\u5305\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u548c\u4f7f\u7528Python\u5305\u7ba1\u7406\u5de5\u5177pip\u3001\u8bbe\u7f6e\u865a\u62df\u73af\u5883\u3002<\/strong>\u6211\u4eec\u5c06\u8be6\u7ec6\u89e3\u91ca\u5982\u4f55\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u56e0\u4e3a\u8fd9\u662f\u8bb8\u591a\u521d\u5b66\u8005\u5bb9\u6613\u5ffd\u89c6\u4f46\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\u3002<\/p>\n<\/p>\n<p><p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u4fdd\u8bc1\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884cPython\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u901a\u5e38\u5728Windows\u4e0a\uff0cPython\u4f1a\u5b89\u88c5\u5728\u7c7b\u4f3c\u4e8e<code>C:\\Python39<\/code>\u6216<code>C:\\Users\\&lt;\u7528\u6237\u540d&gt;\\AppData\\Local\\Programs\\Python\\Python39<\/code>\u7684\u76ee\u5f55\u4e0b\u3002\u5728macOS\u548cLinux\u4e0a\uff0cPython\u901a\u5e38\u4f1a\u88ab\u5b89\u88c5\u5728<code>\/usr\/local\/bin\/python3<\/code>\u6216\u8005\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u3002\u627e\u5230Python\u7684\u5b89\u88c5\u76ee\u5f55\u540e\uff0c\u60a8\u9700\u8981\u5c06\u5176\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684<code>PATH<\/code>\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u8fd9\u6837\u505a\u7684\u76ee\u7684\u662f\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u77e5\u9053\u5728\u54ea\u91cc\u53ef\u4ee5\u627e\u5230Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u914d\u7f6ePython\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001WINDOWS\u7cfb\u7edf\u4e0a\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h2>\n<\/p>\n<p><h3>1. \u4e0b\u8f7dPython\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E6%82%A8%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E7%89%88%E6%9C%AC%E3%80%82%E5%AF%B9%E4%BA%8E%E5%A4%A7%E5%A4%9A%E6%95%B0%E7%94%A8%E6%88%B7%EF%BC%8C%E5%BB%BA%E8%AE%AE%E9%80%89%E6%8B%A9%E6%9C%80%E6%96%B0%E7%9A%84%E7%A8%B3%E5%AE%9A%E7%89%88%E6%9C%AC%E3%80%82%E4%B8%8B%E8%BD%BD%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C%E8%BF%90%E8%A1%8C%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u9009\u62e9\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\uff0c\u5efa\u8bae\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002<\/a><\/p>\n<\/p>\n<p><h3>2. \u5b89\u88c5Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u60a8\u4f1a\u770b\u5230\u4e00\u4e2a\u9009\u9879\uff0c\u8be2\u95ee\u662f\u5426\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684<code>PATH<\/code>\u73af\u5883\u53d8\u91cf\u4e2d\u3002<strong>\u52a1\u5fc5\u9009\u4e2d\u6b64\u9009\u9879<\/strong>\uff0c\u56e0\u4e3a\u8fd9\u5c06\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u63a5\u4e0b\u6765\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u5728\u5b89\u88c5\u65f6\u5fd8\u8bb0\u9009\u4e2d\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e\u3002\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u9009\u62e9\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\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002\u5728\u7f16\u8f91\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u5e76\u8f93\u5165Python\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982<code>C:\\Python39<\/code>\uff09\uff0c\u6700\u540e\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<p><h3>4. \u5b89\u88c5\u548c\u4f7f\u7528pip<\/h3>\n<\/p>\n<p><p>Pip\u901a\u5e38\u4f1a\u968f\u7740Python\u4e00\u8d77\u5b89\u88c5\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>pip --version<\/code>\u6765\u68c0\u67e5pip\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679c\u5df2\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230pip\u7684\u7248\u672c\u4fe1\u606f\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u6765\u5b89\u88c5Python\u5305\uff0c\u4f8b\u5982\uff0c\u8f93\u5165<code>pip install requests<\/code>\u6765\u5b89\u88c5requests\u5e93\u3002<\/p>\n<\/p>\n<p><h3>5. \u8bbe\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u5141\u8bb8\u60a8\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684\u5305\u800c\u4e0d\u5e72\u6270\u5176\u4ed6\u9879\u76ee\u3002\u8981\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u9996\u5148\u786e\u4fdd\u60a8\u5b89\u88c5\u4e86<code>virtualenv<\/code>\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip install virtualenv<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u7136\u540e\uff0c\u5bfc\u822a\u5230\u60a8\u7684\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c<code>python -m venv env<\/code>\u6765\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>env<\/code>\u7684\u865a\u62df\u73af\u5883\u3002\u8981\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884c<code>.\\env\\Scripts\\activate<\/code>\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001MACOS\u7cfb\u7edf\u4e0a\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528Homebrew\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u5305\u7ba1\u7406\u5668\uff0c\u4f7f\u7528\u5b83\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Homebrew\uff08\u5982\u679c\u60a8\u8fd8\u6ca1\u6709\u5b89\u88c5\uff09\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><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python3 --version<\/code>\u548c<code>pip3 --version<\/code>\u6765\u9a8c\u8bc1Python\u548cpip\u662f\u5426\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>macOS\u901a\u5e38\u4f1a\u81ea\u52a8\u914d\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\uff0c\u4f46\u5982\u679c\u60a8\u9700\u8981\u624b\u52a8\u914d\u7f6e\uff0c\u53ef\u4ee5\u7f16\u8f91<code>~\/.bash_profile<\/code>\u6216<code>~\/.zshrc<\/code>\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u6587\u4ef6\u540e\uff0c\u8fd0\u884c<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.zshrc<\/code>\u6765\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h3>4. \u4f7f\u7528pip\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u4e0eWindows\u7c7b\u4f3c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u6765\u5b89\u88c5Python\u5305\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip3 install &lt;package-name&gt;<\/code>\u6765\u5b89\u88c5\u6240\u9700\u7684\u5305\u3002<\/p>\n<\/p>\n<p><h3>5. \u8bbe\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728macOS\u4e0a\uff0c\u60a8\u540c\u6837\u53ef\u4ee5\u4f7f\u7528<code>virtualenv<\/code>\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u9996\u5148\u5b89\u88c5<code>virtualenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u521b\u5efa\u5e76\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv env<\/p>\n<p>source env\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001LINUX\u7cfb\u7edf\u4e0a\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5728Linux\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Python\u3002\u5bf9\u4e8eDebian\/Ubuntu\u7cfb\u7edf\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python3 python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5bf9\u4e8eRed Hat\/CentOS\u7cfb\u7edf\uff0c\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python3 python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 --version<\/code>\u548c<code>pip3 --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u901a\u5e38\uff0cLinux\u4f1a\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u9700\u8981\u624b\u52a8\u914d\u7f6e\uff0c\u53ef\u4ee5\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.bash_profile<\/code>\u6587\u4ef6\uff0c\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u540e\uff0c\u8fd0\u884c<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.bash_profile<\/code>\u6765\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h3>4. \u4f7f\u7528pip\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u6765\u5b89\u88c5Python\u5305\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip3 install &lt;package-name&gt;<\/code>\u6765\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>5. \u8bbe\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728Linux\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>virtualenv<\/code>\u6216Python\u81ea\u5e26\u7684<code>venv<\/code>\u6a21\u5757\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u9996\u5148\u5b89\u88c5<code>virtualenv<\/code>\uff08\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u521b\u5efa\u5e76\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv env<\/p>\n<p>source env\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h2>\n<\/p>\n<p><h3>1. Python\u7248\u672c\u51b2\u7a81<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u7cfb\u7edf\u4e2d\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u7248\u672c\u51b2\u7a81\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u660e\u786e\u6307\u5b9a\u7248\u672c\u53f7\uff0c\u4f8b\u5982\u4f7f\u7528<code>python3<\/code>\u548c<code>pip3<\/code>\u800c\u4e0d\u662f<code>python<\/code>\u548c<code>pip<\/code>\u3002<\/p>\n<\/p>\n<p><h3>2. \u65e0\u6cd5\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u9047\u5230\u5305\u5b89\u88c5\u5931\u8d25\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528<code>--user<\/code>\u9009\u9879\u6765\u5b89\u88c5\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install &lt;package-name&gt; --user<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u5c06\u5305\u5b89\u88c5\u5230\u7528\u6237\u7684\u672c\u5730\u76ee\u5f55\u4e2d\uff0c\u907f\u514d\u6743\u9650\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>3. \u865a\u62df\u73af\u5883\u6fc0\u6d3b\u5931\u8d25<\/h3>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u6743\u9650\u95ee\u9898\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u6216\u8005\u8c03\u6574\u7cfb\u7edf\u7684\u6267\u884c\u7b56\u7565\uff08\u4ec5\u5efa\u8bae\u9ad8\u7ea7\u7528\u6237\u64cd\u4f5c\uff09\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u6210\u529f\u5b89\u88c5\u548c\u914d\u7f6ePython\uff0c\u5e76\u521b\u5efa\u9002\u5408\u60a8\u5f00\u53d1\u73af\u5883\u7684\u865a\u62df\u73af\u5883\u3002\u65e0\u8bba\u60a8\u662f\u5728Windows\u3001macOS\u8fd8\u662fLinux\u4e0a\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u6307\u5bfc\u65b9\u9488\u90fd\u80fd\u5e2e\u52a9\u60a8\u987a\u5229\u5b8c\u6210Python\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u8fdb\u884c\u5b89\u88c5\uff1f<\/strong><br \/>\u5728\u5b89\u88c5Python\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u975e\u5e38\u91cd\u8981\u3002\u5efa\u8bae\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u9879\u76ee\u9700\u6c42\u9009\u62e9\u3002\u4e00\u822c\u6765\u8bf4\uff0cPython 3.x\u7cfb\u5217\u662f\u63a8\u8350\u7684\u7248\u672c\uff0c\u56e0\u4e3a\u5b83\u5305\u542b\u4e86\u8bb8\u591a\u65b0\u7684\u529f\u80fd\u548c\u6539\u8fdb\uff0c\u4e14\u9010\u6e10\u66ff\u4ee3\u4e86Python 2.x\u3002\u5982\u679c\u4f60\u662f\u521d\u5b66\u8005\uff0c\u53ef\u4ee5\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\uff0c\u8fd9\u6837\u53ef\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u652f\u6301\u548c\u66f4\u591a\u7684\u5e93\u3002<\/p>\n<p><strong>\u5728Windows\u548cMac\u4e0a\u5b89\u88c5Python\u7684\u6b65\u9aa4\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728Windows\u4e0a\uff0c\u4f60\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u7f51\uff0c\u4e0b\u8f7d\u9002\u5408\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u65f6\uff0c\u8bf7\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u3002\u5728Mac\u4e0a\uff0c\u5efa\u8bae\u4f7f\u7528Homebrew\u8fdb\u884c\u5b89\u88c5\uff0c\u8f93\u5165\u547d\u4ee4 <code>brew install python<\/code> \u4f1a\u66f4\u52a0\u65b9\u4fbf\u3002\u6b64\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4ece\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5982\u4f55\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>python --version<\/code> \u6216 <code>python3 --version<\/code>\uff0c\u5982\u679c\u663e\u793a\u51faPython\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002\u8fd8\u53ef\u4ee5\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u73af\u5883\uff0c\u8f93\u5165 <code>python<\/code> \u6216 <code>python3<\/code>\uff0c\u5982\u679c\u51fa\u73b0\u4e86\u63d0\u793a\u7b26\uff08&gt;&gt;&gt;\uff09\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6b63\u786e\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\u7684\u6700\u4f73\u5b9e\u8df5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u4f7f\u7528<code>pip<\/code>\u662f\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\u7684\u6807\u51c6\u65b9\u5f0f\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>pip install package_name<\/code>\uff08\u5c06<code>package_name<\/code>\u66ff\u6362\u4e3a\u5b9e\u9645\u5e93\u540d\uff09\u5373\u53ef\u5b89\u88c5\u6240\u9700\u5e93\u3002\u4e3a\u4e86\u907f\u514d\u5e93\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u5982<code>venv<\/code>\u6216<code>virtualenv<\/code>\uff0c\u8fd9\u6837\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684\u73af\u5883\uff0c\u786e\u4fdd\u4f9d\u8d56\u7ba1\u7406\u66f4\u52a0\u6e05\u6670\u548c\u5b89\u5168\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b89\u88c5\u548c\u914d\u7f6ePython\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4e0b\u8f7dPython\u5b89\u88c5\u5305\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u548c\u4f7f [&hellip;]","protected":false},"author":3,"featured_media":996167,"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\/996164"}],"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=996164"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/996164\/revisions"}],"predecessor-version":[{"id":996168,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/996164\/revisions\/996168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/996167"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=996164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=996164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=996164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}