{"id":995105,"date":"2024-12-27T09:02:03","date_gmt":"2024-12-27T01:02:03","guid":{"rendered":""},"modified":"2024-12-27T09:02:06","modified_gmt":"2024-12-27T01:02:06","slug":"%e5%a6%82%e4%bd%95%e6%8a%8apython%e8%ae%be%e7%bd%ae%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/995105.html","title":{"rendered":"\u5982\u4f55\u628apython\u8bbe\u7f6e\u73af\u5883"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25071847\/5b01206b-8d84-4711-ac33-6a3fd65cdc62.webp\" alt=\"\u5982\u4f55\u628apython\u8bbe\u7f6e\u73af\u5883\" \/><\/p>\n<p><p> <strong>\u8981\u628aPython\u8bbe\u7f6e\u73af\u5883\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177\u3001\u8bbe\u7f6e\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883<\/strong>\u3002<strong>\u5b89\u88c5Python<\/strong>\u662f\u7b2c\u4e00\u6b65\uff0c\u786e\u4fdd\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\uff1b<strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\u9700\u8981\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\uff1b<strong>\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177<\/strong>\u5982<code>venv<\/code>\u6216<code>virtualenv<\/code>\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u9879\u76ee\u4e2d\u521b\u5efa\u9694\u79bb\u7684Python\u73af\u5883\uff1b\u6700\u540e\uff0c<strong>\u8bbe\u7f6e\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883<\/strong>\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u547d\u4ee4\uff0c\u5982\u521b\u5efa\u3001\u6fc0\u6d3b\u548c\u9000\u51fa\u865a\u62df\u73af\u5883\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5728\u8bbe\u7f6ePython\u73af\u5883\u4e4b\u524d\uff0c\u9996\u5148\u8981\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86Python\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5Python\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u524d\u5f80Python\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%AF%BC%E8%88%AA%E5%88%B0%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5bfc\u822a\u5230\u4e0b\u8f7d\u9875\u9762\u3002<\/a><\/li>\n<li>\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001macOS\u3001Linux\uff09\uff0c\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u4e0b\u8f7d\u3002\u901a\u5e38\uff0c\u5efa\u8bae\u4e0b\u8f7d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u53cc\u51fb\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u6587\u4ef6\uff0c\u542f\u52a8\u5b89\u88c5\u5411\u5bfc\u3002<\/li>\n<li>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u81ea\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li>\u5bf9\u4e8emacOS\u548cLinux\uff0c\u5b89\u88c5\u8fc7\u7a0b\u4f1a\u7565\u6709\u4e0d\u540c\uff0c\u4f46\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u662f\u76f4\u63a5\u89e3\u538b\u6216\u8005\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08macOS\/Linux\uff09\u3002<\/li>\n<li>\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u67e5\u770b\u662f\u5426\u6b63\u786e\u5b89\u88c5\u4e86Python\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u786e\u4fdd\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u7684\u5173\u952e\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows\u7cfb\u7edf<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\uff0c\u627e\u5230\u201cPath\u201d\u53d8\u91cf\uff0c\u53cc\u51fb\u6253\u5f00\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u65b0\u5efa\u201d\uff0c\u5c06Python\u5b89\u88c5\u76ee\u5f55\uff08\u5982<code>C:\\Python39<\/code>\uff09\u548cScripts\u76ee\u5f55\uff08\u5982<code>C:\\Python39\\Scripts<\/code>\uff09\u6dfb\u52a0\u5230Path\u4e2d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux\u7cfb\u7edf<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u7f16\u8f91<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\uff08\u5177\u4f53\u54ea\u4e2a\u6587\u4ef6\u53d6\u51b3\u4e8e\u4f60\u7684shell\u914d\u7f6e\uff09\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a\n<pre><code>export PATH=&quot;\/usr\/local\/bin\/python3.9:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4f7f\u7528<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.bash_profile<\/code>\u547d\u4ee4\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u865a\u62df\u73af\u5883\u5de5\u5177\u7528\u4e8e\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u53ef\u4ee5\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5<code>venv<\/code>\uff08Python 3.3\u53ca\u4ee5\u4e0a\u7248\u672c\u81ea\u5e26\uff09<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>venv<\/code>\u662fPython\u81ea\u5e26\u7684\u865a\u62df\u73af\u5883\u6a21\u5757\uff0c\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python -m venv &lt;env_name&gt;<\/code>\u5373\u53ef\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5<code>virtualenv<\/code>\uff08\u9002\u7528\u4e8ePython 2\u548c3\uff09<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528pip\u5b89\u88c5<code>virtualenv<\/code>\uff1a<code>pip install virtualenv<\/code><\/li>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<code>virtualenv &lt;env_name&gt;<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5bf9\u4e8ePython 3\u7528\u6237\uff0c\u5efa\u8bae\u4f7f\u7528<code>venv<\/code>\uff0c\u56e0\u4e3a\u5b83\u662fPython\u81ea\u5e26\u7684\u6a21\u5757\uff0c\u7b80\u5355\u6613\u7528\u3002<\/li>\n<li>\u5bf9\u4e8e\u9700\u8981\u652f\u6301Python 2\u7684\u9879\u76ee\uff0c\u53ef\u4ee5\u9009\u62e9<code>virtualenv<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u8bbe\u7f6e\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u5141\u8bb8\u4f60\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u9694\u79bbPython\u5305\u548c\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>venv<\/code>\uff1a<code>python -m venv my_env<\/code><\/li>\n<li>\u4f7f\u7528<code>virtualenv<\/code>\uff1a<code>virtualenv my_env<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e2d\uff1a<code>my_env\\Scripts\\activate<\/code><\/li>\n<li>\u5728macOS\/Linux\u4e2d\uff1a<code>source my_env\/bin\/activate<\/code><\/li>\n<li>\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u884c\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u63d0\u793a\u4f60\u5df2\u8fdb\u5165\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f7f\u7528<code>pip install &lt;package_name&gt;<\/code>\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684Python\u5305\u3002<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7<code>pip freeze &gt; requirements.txt<\/code>\u547d\u4ee4\u5c06\u5f53\u524d\u73af\u5883\u7684\u6240\u6709\u4f9d\u8d56\u5bfc\u51fa\u5230<code>requirements.txt<\/code>\u6587\u4ef6\u4e2d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>deactivate<\/code>\u547d\u4ee4\u5373\u53ef\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5220\u9664\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u76f4\u63a5\u5220\u9664\u865a\u62df\u73af\u5883\u6587\u4ef6\u5939\u5373\u53ef\uff0c\u5982<code>rm -rf my_env<\/code>\uff08macOS\/Linux\uff09\u6216\u901a\u8fc7\u6587\u4ef6<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/58557.html\" target=\"_blank\">\u8d44\u6e90\u7ba1\u7406<\/a>\u5668\u5220\u9664\uff08Windows\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<p><p>\u5728\u8bbe\u7f6ePython\u73af\u5883\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Python\u547d\u4ee4\u65e0\u6548<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u63d0\u793a\u627e\u4e0d\u5230\u7a0b\u5e8f\uff0c\u53ef\u80fd\u662f\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u4e0d\u6b63\u786e\u3002\u8bf7\u786e\u4fddPython\u5b89\u88c5\u8def\u5f84\u5df2\u6b63\u786e\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u4e2d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>pip\u547d\u4ee4\u65e0\u6548<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u5b89\u88c5Python\u65f6\u6ca1\u6709\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4pip\u547d\u4ee4\u65e0\u6548\u3002\u53ef\u4ee5\u624b\u52a8\u6dfb\u52a0Python\u7684Scripts\u76ee\u5f55\u5230PATH\u4e2d\uff0c\u6216\u8005\u91cd\u65b0\u5b89\u88c5Python\u5e76\u52fe\u9009\u8be5\u9009\u9879\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883\u65e0\u6cd5\u6fc0\u6d3b<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e2d\uff0c\u53ef\u80fd\u7531\u4e8e\u6743\u9650\u95ee\u9898\u65e0\u6cd5\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/li>\n<li>\u5728macOS\/Linux\u4e2d\uff0c\u786e\u4fdd\u4f7f\u7528<code>source<\/code>\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u6267\u884c<code>activate<\/code>\u811a\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u51b2\u7a81<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728\u540c\u4e00\u4e2a\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684\u4f9d\u8d56\u5305\u53ef\u80fd\u5bfc\u81f4\u51b2\u7a81\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u6709\u6548\u907f\u514d\u8fd9\u79cd\u95ee\u9898\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u6709\u72ec\u7acb\u7684\u4f9d\u8d56\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u6210\u529f\u8bbe\u7f6ePython\u73af\u5883\u5e76\u4f7f\u7528\u865a\u62df\u73af\u5883\u5de5\u5177\u6765\u7ba1\u7406\u4f60\u7684\u9879\u76ee\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u5f97\u5230\u826f\u597d\u7684\u7ba1\u7406\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684Python\u7248\u672c\u8fdb\u884c\u73af\u5883\u8bbe\u7f6e\uff1f<\/strong><br \/>\u5728\u8bbe\u7f6ePython\u73af\u5883\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u975e\u5e38\u91cd\u8981\u3002\u901a\u5e38\uff0c\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\uff0c\u56e0\u5176\u5305\u542b\u4e86\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u4fee\u590d\u3002\u5982\u679c\u60a8\u7684\u9879\u76ee\u4f9d\u8d56\u4e8e\u7279\u5b9a\u7248\u672c\u7684\u5e93\u6216\u6846\u67b6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528Anaconda\u6216pyenv\u7b49\u5de5\u5177\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u4ee5\u4fbf\u4e8e\u5728\u4e0d\u540c\u9879\u76ee\u95f4\u5207\u6362\u3002<\/p>\n<p><strong>\u5728Windows\u548cMac\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u521b\u5efaPython\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u5728Windows\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6216PowerShell\uff0c\u8f93\u5165<code>python -m venv myenv<\/code>\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5bf9\u4e8eMac\u7528\u6237\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u4f7f\u7528\u76f8\u540c\u7684\u547d\u4ee4\u3002\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u4f7f\u7528<code>myenv\\Scripts\\activate<\/code>\uff08Windows\uff09\u6216<code>source myenv\/bin\/activate<\/code>\uff08Mac\uff09\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u540e\uff0c\u6240\u6709\u5b89\u88c5\u7684\u5e93\u5c06\u53ea\u5f71\u54cd\u8be5\u7279\u5b9a\u73af\u5883\uff0c\u907f\u514d\u4e86\u4f9d\u8d56\u51b2\u7a81\u3002<\/p>\n<p><strong>\u5728Python\u73af\u5883\u4e2d\uff0c\u5982\u4f55\u7ba1\u7406\u548c\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u5305\uff1f<\/strong><br \/>\u4f7f\u7528<code>pip<\/code>\u662f\u7ba1\u7406Python\u4f9d\u8d56\u5305\u7684\u5e38\u89c1\u65b9\u5f0f\u3002\u5728\u521b\u5efa\u5e76\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip install package_name<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u5e93\u3002\u4e3a\u4e86\u65b9\u4fbf\u9879\u76ee\u7684\u4f9d\u8d56\u7ba1\u7406\uff0c\u5efa\u8bae\u521b\u5efa\u4e00\u4e2a<code>requirements.txt<\/code>\u6587\u4ef6\uff0c\u8bb0\u5f55\u6240\u6709\u4f9d\u8d56\u5305\u53ca\u5176\u7248\u672c\uff0c\u4f7f\u7528<code>pip freeze &gt; requirements.txt<\/code>\u751f\u6210\uff0c\u4e4b\u540e\u53ef\u4ee5\u901a\u8fc7<code>pip install -r requirements.txt<\/code>\u5feb\u901f\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u5305\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u628aPython\u8bbe\u7f6e\u73af\u5883\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177\u3001\u8bbe\u7f6e\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\u3002\u5b89\u88c5P [&hellip;]","protected":false},"author":3,"featured_media":995114,"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\/995105"}],"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=995105"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/995105\/revisions"}],"predecessor-version":[{"id":995115,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/995105\/revisions\/995115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/995114"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=995105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=995105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=995105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}