{"id":926413,"date":"2024-12-26T15:50:54","date_gmt":"2024-12-26T07:50:54","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/926413.html"},"modified":"2024-12-26T15:50:57","modified_gmt":"2024-12-26T07:50:57","slug":"python%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/926413.html","title":{"rendered":"python\u5982\u4f55\u8bbe\u7f6e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063030\/8c832744-c180-4513-bbae-ccfd39342c5b.webp\" alt=\"python\u5982\u4f55\u8bbe\u7f6e\" \/><\/p>\n<p><p> <strong>Python\u8bbe\u7f6e\u7684\u6838\u5fc3\u5305\u62ec\uff1a\u5b89\u88c5Python\u73af\u5883\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002<\/strong>\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u4e2a\u6838\u5fc3\u6b65\u9aa4\uff0c\u5373\u5982\u4f55\u5b89\u88c5Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5Python\u73af\u5883\u662f\u5b66\u4e60\u548c\u4f7f\u7528Python\u8bed\u8a00\u7684\u7b2c\u4e00\u6b65\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002\u901a\u5e38\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u63d0\u4f9b\u4e24\u79cd\u7248\u672c\uff1aPython 2.x\u548cPython 3.x\u3002\u5efa\u8bae\u9009\u62e9Python 3.x\uff0c\u56e0\u4e3aPython 2.x\u5df2\u7ecf\u505c\u6b62\u66f4\u65b0\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u6587\u4ef6\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u5efa\u8bae\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8Python\u7684\u8bbe\u7f6e\u548c\u914d\u7f6e\u8fc7\u7a0b\uff0c\u5e2e\u52a9\u60a8\u5feb\u901f\u5165\u95e8\u5e76\u9ad8\u6548\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5b89\u88c5Python\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4f7f\u7528Python\u4e4b\u524d\uff0c\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\u3002Python\u53ef\u4ee5\u5728Windows\u3001macOS\u548cLinux\u4e0a\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>1. Windows\u4e0a\u7684\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E9%80%82%E5%90%88%E6%82%A8%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84%E7%9A%84Python%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%EF%BC%88%E9%80%9A%E5%B8%B8%E6%98%AFPython\">https:\/\/www.python.org\/\uff09\uff0c\u4e0b\u8f7d\u9002\u5408\u60a8\u7cfb\u7edf\u67b6\u6784\u7684Python\u5b89\u88c5\u7a0b\u5e8f\uff08\u901a\u5e38\u662fPython<\/a> 3.x\u7248\u672c\uff09\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u52a1\u5fc5\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4f7f\u5176\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u53ef\u7528\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u5e76\u8f93\u5165<code>python --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u5982\u679c\u770b\u5230Python\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>2. macOS\u4e0a\u7684\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>macOS\u901a\u5e38\u81ea\u5e26Python 2.x\u7248\u672c\uff0c\u4f46\u5efa\u8bae\u4f7f\u7528Python 3.x\u3002\u53ef\u4ee5\u901a\u8fc7Homebrew\u6765\u5b89\u88c5Python 3.x\u3002\u9996\u5148\uff0c\u786e\u4fddHomebrew\u5df2\u5b89\u88c5\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Homebrew\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5Python 3.x\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230\u60a8\u7684Shell\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528<code>python3 --version<\/code>\u547d\u4ee4\u68c0\u67e5\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>3. Linux\u4e0a\u7684\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u81ea\u5e26Python\uff0c\u4f46\u901a\u5e38\u662fPython 2.x\u7248\u672c\u3002\u8981\u5b89\u88c5Python 3.x\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\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<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u540e\uff0c\u901a\u8fc7<code>python3 --version<\/code>\u547d\u4ee4\u9a8c\u8bc1\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u914d\u7f6ePython\u73af\u5883\u53d8\u91cf<\/h2>\n<\/p>\n<p><p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u786e\u4fddPython\u53ca\u5176\u76f8\u5173\u5de5\u5177\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u7528\u7684\u91cd\u8981\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>1. Windows\u4e0a\u7684\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728Windows\u4e2d\uff0c\u5b89\u88c5Python\u65f6\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\u4f1a\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u6ca1\u6709\u9009\u62e9\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e\u3002\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\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\u7136\u540e\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u201cPath\u201d\u5e76\u7f16\u8f91\uff0c\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\uff08\u5982<code>C:\\Python39<\/code>\uff09\u6dfb\u52a0\u8fdb\u53bb\u3002<\/p>\n<\/p>\n<p><h3>2. macOS\u548cLinux\u4e0a\u7684\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u4e0a\uff0c\u73af\u5883\u53d8\u91cf\u901a\u5e38\u901a\u8fc7Shell\u914d\u7f6e\u6587\u4ef6\u8bbe\u7f6e\uff0c\u5982<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e9b\u6587\u4ef6\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u884c\u6765\u8bbe\u7f6ePython\u8def\u5f84\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 ~\/.bashrc<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/h2>\n<\/p>\n<p><p>Python\u6709\u4e00\u4e2a\u4e30\u5bcc\u7684\u751f\u6001\u7cfb\u7edf\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e93\u6765\u6269\u5c55\u5176\u529f\u80fd\u3002\u4f7f\u7528<code>pip<\/code>\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406Python\u5e93\u3002<\/p>\n<\/p>\n<p><h3>1. \u4f7f\u7528pip\u5b89\u88c5\u5e93<\/h3>\n<\/p>\n<p><p><code>pip<\/code>\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u901a\u5e38\u4e0ePython\u4e00\u8d77\u5b89\u88c5\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5b89\u88c5NumPy\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u7ba1\u7406\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u5141\u8bb8\u60a8\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u51b2\u7a81\u3002\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728macOS\u548cLinux\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u5e93\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h2>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684IDE\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><h3>1. PyCharm<\/h3>\n<\/p>\n<p><p>PyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5f00\u53d1\u7684\u4e13\u4e1aPython IDE\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u529f\u80fd\u3001\u8c03\u8bd5\u5de5\u5177\u548c\u96c6\u6210\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002PyCharm\u6709\u793e\u533a\u7248\uff08\u514d\u8d39\uff09\u548c\u4e13\u4e1a\u7248\uff08\u4ed8\u8d39\uff09\uff0c\u793e\u533a\u7248\u5df2\u7ecf\u8db3\u591f\u6ee1\u8db3\u5927\u591a\u6570\u5f00\u53d1\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>2. Visual Studio Code<\/h3>\n<\/p>\n<p><p>Visual Studio Code\uff08VSCode\uff09\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301Python\u6269\u5c55\u3002\u5b89\u88c5Python\u6269\u5c55\u540e\uff0cVSCode\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>3. Jupyter Notebook<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7684Python\u73af\u5883\uff0c\u9002\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u79d1\u5b66\u8ba1\u7b97\u3002\u5b83\u5141\u8bb8\u60a8\u5728\u4e00\u4e2a\u6587\u6863\u4e2d\u7f16\u5199\u548c\u6267\u884c\u4ee3\u7801\u3001\u53ef\u89c6\u5316\u7ed3\u679c\u5e76\u6dfb\u52a0\u6ce8\u91ca\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u540e\uff0c\u4f7f\u7528<code>jupyter notebook<\/code>\u547d\u4ee4\u542f\u52a8\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u603b\u7ed3\u4e0e\u5efa\u8bae<\/h2>\n<\/p>\n<p><p>\u5728\u914d\u7f6ePython\u73af\u5883\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u548c\u5de5\u5177\u662f\u6210\u529f\u7684\u5173\u952e\u3002\u5b89\u88c5Python 3.x\u5e76\u786e\u4fdd\u5176\u8def\u5f84\u6b63\u786e\u914d\u7f6e\u662f\u57fa\u7840\u3002\u901a\u8fc7<code>pip<\/code>\u7ba1\u7406\u5e93\u548c\u4f9d\u8d56\u5173\u7cfb\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\uff0c\u9009\u62e9\u9002\u5408\u7684IDE\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u7ecf\u9a8c\u4e30\u5bcc\u7684\u5f00\u53d1\u8005\uff0c\u826f\u597d\u7684\u73af\u5883\u914d\u7f6e\u90fd\u80fd\u663e\u8457\u63d0\u5347\u5de5\u4f5c\u6548\u7387\u548c\u7f16\u7a0b\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><p>\u786e\u4fdd\u5b9a\u671f\u66f4\u65b0Python\u548c\u5df2\u5b89\u88c5\u5e93\uff0c\u4ee5\u83b7\u53d6\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u8865\u4e01\u3002\u6b64\u5916\uff0c\u79ef\u6781\u53c2\u4e0ePython\u793e\u533a\uff0c\u83b7\u53d6\u66f4\u591a\u7684\u5b66\u4e60\u8d44\u6e90\u548c\u652f\u6301\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u60a8\u6210\u529f\u8bbe\u7f6ePython\u73af\u5883\u5e76\u987a\u5229\u5f00\u59cbPython\u7f16\u7a0b\u4e4b\u65c5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bbe\u7f6e\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u865a\u62df\u73af\u5883\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u5de5\u4f5c\u7a7a\u95f4\uff0c\u53ef\u4ee5\u7528\u4e8e\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u5305\u7248\u672c\u3002\u8981\u8bbe\u7f6e\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684<code>venv<\/code>\u6a21\u5757\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a  <\/p>\n<pre><code>python -m venv myenv\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u7684<code>myenv<\/code>\u662f\u4f60\u60f3\u8981\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002\u521b\u5efa\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u8be5\u73af\u5883\uff1a  <\/p>\n<ul>\n<li>\u5728Windows\u4e0a\uff1a<\/li>\n<\/ul>\n<pre><code>myenv\\Scripts\\activate\n<\/code><\/pre>\n<ul>\n<li>\u5728macOS\u548cLinux\u4e0a\uff1a<\/li>\n<\/ul>\n<pre><code>source myenv\/bin\/activate\n<\/code><\/pre>\n<p>\u6fc0\u6d3b\u540e\uff0c\u6240\u6709\u7684\u5305\u5b89\u88c5\u5c06\u53ea\u5f71\u54cd\u8be5\u865a\u62df\u73af\u5883\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\uff1f<\/strong><br \/>\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\u901a\u5e38\u4f7f\u7528<code>pip<\/code>\u5de5\u5177\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u67d0\u4e2a\u5305\uff1a  <\/p>\n<pre><code>pip install package_name\n<\/code><\/pre>\n<p>\u8981\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a  <\/p>\n<pre><code>pip list\n<\/code><\/pre>\n<p>\u5982\u679c\u9700\u8981\u5378\u8f7d\u67d0\u4e2a\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a  <\/p>\n<pre><code>pip uninstall package_name\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u4f7f\u7528<code>requirements.txt<\/code>\u6587\u4ef6\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u9879\uff0c\u901a\u8fc7\u8fd0\u884c\uff1a  <\/p>\n<pre><code>pip install -r requirements.txt\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u4e00\u6b21\u6027\u5b89\u88c5\u6587\u4ef6\u4e2d\u5217\u51fa\u7684\u6240\u6709\u5305\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bbe\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u8bbe\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\u6709\u52a9\u4e8e\u5728\u547d\u4ee4\u884c\u4e2d\u65b9\u4fbf\u5730\u8fd0\u884cPython\u811a\u672c\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8bbe\u7f6e\uff1a  <\/p>\n<ol>\n<li>\u641c\u7d22\u201c\u73af\u5883\u53d8\u91cf\u201d\uff0c\u6253\u5f00\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u5bf9\u8bdd\u6846\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\u627e\u5230\u201cPath\u201d\u53d8\u91cf\uff0c\u9009\u62e9\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982\uff1a<code>C:\\Python39<\/code>\uff09\u548c<code>Scripts<\/code>\u6587\u4ef6\u5939\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1a<code>C:\\Python39\\Scripts<\/code>\uff09\u3002<\/li>\n<li>\u786e\u8ba4\u66f4\u6539\u5e76\u91cd\u542f\u547d\u4ee4\u63d0\u793a\u7b26\u3002<br \/>\u5bf9\u4e8emacOS\u548cLinux\u7528\u6237\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u7f16\u8f91<code>~\/.bash_profile<\/code>\u6216<code>~\/.bashrc<\/code>\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ol>\n<pre><code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u5e76\u8fd0\u884c<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.bashrc<\/code>\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8bbe\u7f6e\u7684\u6838\u5fc3\u5305\u62ec\uff1a\u5b89\u88c5Python\u73af\u5883\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002\u4ee5\u4e0b [&hellip;]","protected":false},"author":3,"featured_media":926419,"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\/926413"}],"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=926413"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/926413\/revisions"}],"predecessor-version":[{"id":926424,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/926413\/revisions\/926424"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/926419"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=926413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=926413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=926413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}