{"id":1107285,"date":"2025-01-08T16:48:11","date_gmt":"2025-01-08T08:48:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1107285.html"},"modified":"2025-01-08T16:48:14","modified_gmt":"2025-01-08T08:48:14","slug":"python%e5%ae%89%e8%a3%85%e5%88%b0%e4%ba%86%e4%b8%ad%e6%96%87%e8%b7%af%e5%be%84%e4%b8%8b%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1107285.html","title":{"rendered":"python\u5b89\u88c5\u5230\u4e86\u4e2d\u6587\u8def\u5f84\u4e0b\u5982\u4f55\u4fee\u6539"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25071403\/668f548a-53f5-47ab-a956-90aae12b25a5.webp\" alt=\"python\u5b89\u88c5\u5230\u4e86\u4e2d\u6587\u8def\u5f84\u4e0b\u5982\u4f55\u4fee\u6539\" \/><\/p>\n<p><p> <strong>\u8981\u89e3\u51b3Python\u5b89\u88c5\u5230\u4e86\u4e2d\u6587\u8def\u5f84\u4e0b\u7684\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u82f1\u6587\u8def\u5f84\u4e0b\u3001\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3001\u6216\u8005\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u907f\u514d\u8def\u5f84\u95ee\u9898\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u82f1\u6587\u8def\u5f84<\/strong>\u4e0b\u662f\u6700\u76f4\u63a5\u548c\u63a8\u8350\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u5f7b\u5e95\u89e3\u51b3\u7531\u4e8e\u8def\u5f84\u95ee\u9898\u5bfc\u81f4\u7684\u5404\u79cd\u6f5c\u5728\u9519\u8bef\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u82f1\u6587\u8def\u5f84<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u4e0d\u542b\u4e2d\u6587\u5b57\u7b26\u7684\u8def\u5f84\u4e0b\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5378\u8f7d\u5f53\u524d\u7684Python\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u9009\u62e9\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u3002<\/li>\n<li>\u627e\u5230Python\u76f8\u5173\u7684\u6761\u76ee\uff0c\u53f3\u952e\u9009\u62e9\u201c\u5378\u8f7d\u201d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00Python\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%E7%94%A8%E4%BA%8E%E4%BD%A0%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8e\u4f60\u7cfb\u7edf\u7684Python\u5b89\u88c5\u7a0b\u5e8f\u3002<\/a><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python\u5230\u82f1\u6587\u8def\u5f84<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8fd0\u884c\u4e0b\u8f7d\u7684Python\u5b89\u88c5\u7a0b\u5e8f\u3002<\/li>\n<li>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u9009\u62e9\u201cCustomize installation\u201d\u3002<\/li>\n<li>\u5728\u201cOptional Features\u201d\u9875\u9762\uff0c\u52fe\u9009\u9700\u8981\u7684\u529f\u80fd\uff0c\u70b9\u51fb\u201cNext\u201d\u3002<\/li>\n<li>\u5728\u201cAdvanced Options\u201d\u9875\u9762\uff0c\u9009\u62e9\u4e00\u4e2a\u4e0d\u542b\u4e2d\u6587\u5b57\u7b26\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u6bd4\u5982 <code>C:\\Python39<\/code>\u3002<\/li>\n<li>\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u9009\u62e9\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u7cfb\u7edf\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<code>Path<\/code>\u53d8\u91cf\uff0c\u9009\u62e9\u5b83\u5e76\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u548cScripts\u8def\u5f84\uff0c\u6bd4\u5982 <code>C:\\Python39<\/code> \u548c <code>C:\\Python39\\Scripts<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4e0d\u60f3\u91cd\u65b0\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u73af\u5883\u53d8\u91cf\u6765\u907f\u514dPython\u56e0\u4e2d\u6587\u8def\u5f84\u800c\u51fa\u73b0\u7684\u95ee\u9898\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u786e\u5b9a\u4f60\u5f53\u524dPython\u5b89\u88c5\u7684\u8def\u5f84\uff0c\u6bd4\u5982 <code>C:\\\u7528\u6237\\\u7528\u6237\u540d\\Python<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u9009\u62e9\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u7cfb\u7edf\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<code>Path<\/code>\u53d8\u91cf\uff0c\u9009\u62e9\u5b83\u5e76\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230<code>Path<\/code>\u53d8\u91cf\u4e2d\uff0c\u786e\u4fdd\u8def\u5f84\u4e0d\u5305\u542b\u4e2d\u6587\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u914d\u7f6e<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165 <code>python<\/code>\uff0c\u68c0\u67e5\u662f\u5426\u80fd\u591f\u6b63\u786e\u542f\u52a8Python\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u907f\u514d\u7531\u4e8ePython\u5b89\u88c5\u8def\u5f84\u4e2d\u5305\u542b\u4e2d\u6587\u5b57\u7b26\u800c\u5f15\u53d1\u7684\u95ee\u9898\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8fdb\u5165\u4e00\u4e2a\u4e0d\u542b\u4e2d\u6587\u5b57\u7b26\u7684\u76ee\u5f55\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-shell\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e0a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-shell\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728Linux\u6216MacOS\u4e0a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-shell\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u6240\u9700\u7684\u5305<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u4f60\u6240\u9700\u7684Python\u5305\uff0c\u6bd4\u5982\uff1a\n<pre><code class=\"language-shell\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6bcf\u6b21\u4f7f\u7528Python\u65f6\uff0c\u5148\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u6240\u6709\u64cd\u4f5c\u90fd\u5728\u8be5\u73af\u5883\u4e2d\u8fdb\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p><strong>\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u82f1\u6587\u8def\u5f84<\/strong>\u662f\u6700\u76f4\u63a5\u548c\u63a8\u8350\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u5f7b\u5e95\u89e3\u51b3\u7531\u4e8e\u8def\u5f84\u95ee\u9898\u5bfc\u81f4\u7684\u5404\u79cd\u6f5c\u5728\u9519\u8bef\u3002\u540c\u65f6\uff0c<strong>\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/strong>\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u79cd\u5feb\u901f\u89e3\u51b3\u65b9\u6cd5\uff0c\u800c<strong>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/strong>\u5219\u80fd\u5e2e\u52a9\u4f60\u5728\u4e0d\u6539\u53d8\u7cfb\u7edfPython\u914d\u7f6e\u7684\u60c5\u51b5\u4e0b\uff0c\u907f\u514d\u8def\u5f84\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u5e94\u786e\u4fddPython\u7684\u8def\u5f84\u4e2d\u4e0d\u5305\u542b\u4e2d\u6587\u5b57\u7b26\uff0c\u4ee5\u907f\u514d\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\u3002\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u987a\u5229\u5730\u89e3\u51b3Python\u5b89\u88c5\u8def\u5f84\u4e2d\u7684\u4e2d\u6587\u5b57\u7b26\u95ee\u9898\uff0c\u786e\u4fddPython\u73af\u5883\u7684\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u5f53\u524dPython\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u8981\u68c0\u67e5Python\u7684\u5f53\u524d\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python --version<\/code>\u6765\u67e5\u770bPython\u7684\u7248\u672c\u4fe1\u606f\u3002\u5982\u679cPython\u5df2\u7ecf\u5b89\u88c5\uff0c\u901a\u5e38\u4f1a\u663e\u793a\u5b89\u88c5\u76ee\u5f55\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>where python<\/code>\u547d\u4ee4\uff08\u5728Windows\u4e0a\uff09\u6216<code>which python<\/code>\uff08\u5728macOS\u6216Linux\u4e0a\uff09\u6765\u627e\u5230Python\u7684\u5177\u4f53\u8def\u5f84\u3002<\/p>\n<p><strong>Python\u7684\u4e2d\u6587\u8def\u5f84\u4f1a\u5f71\u54cd\u4f7f\u7528\u5417\uff1f<\/strong><br \/>\u662f\u7684\uff0cPython\u7684\u4e2d\u6587\u8def\u5f84\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u95ee\u9898\uff0c\u7279\u522b\u662f\u5728\u4f7f\u7528\u67d0\u4e9b\u5e93\u6216\u6267\u884c\u811a\u672c\u65f6\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e3a\u8def\u5f84\u7f16\u7801\u7684\u95ee\u9898\u5bfc\u81f4\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u6587\u4ef6\u6216\u6a21\u5757\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06Python\u5b89\u88c5\u5728\u82f1\u6587\u8def\u5f84\u4e0b\uff0c\u4ee5\u907f\u514d\u6f5c\u5728\u7684\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u4f55\u91cd\u65b0\u5b89\u88c5Python\u5230\u82f1\u6587\u8def\u5f84\u4e0b\uff1f<\/strong><br \/>\u5982\u679c\u9700\u8981\u5c06Python\u79fb\u52a8\u5230\u82f1\u6587\u8def\u5f84\uff0c\u5efa\u8bae\u5148\u5378\u8f7d\u5f53\u524d\u7684Python\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u63a7\u5236\u9762\u677f\u6216\u547d\u4ee4\u884c\u8fdb\u884c\u5378\u8f7d\u3002\u5378\u8f7d\u540e\uff0c\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\uff0c\u5e76\u9009\u62e9\u4e00\u4e2a\u65e0\u4e2d\u6587\u5b57\u7b26\u7684\u8def\u5f84\u8fdb\u884c\u5b89\u88c5\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9009\u62e9\u6dfb\u52a0Python\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p><strong>\u5982\u4f55\u907f\u514d\u672a\u6765\u5728Windows\u4e0a\u5b89\u88c5Python\u65f6\u4f7f\u7528\u4e2d\u6587\u8def\u5f84\uff1f<\/strong><br \/>\u5728\u5b89\u88c5\u8f6f\u4ef6\u65f6\uff0c\u5efa\u8bae\u59cb\u7ec8\u9009\u62e9\u82f1\u6587\u8def\u5f84\u3002\u53ef\u4ee5\u5728\u5b89\u88c5\u65f6\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\uff0c\u624b\u52a8\u8f93\u5165\u5b89\u88c5\u8def\u5f84\u3002\u4e3a\u4e86\u8fdb\u4e00\u6b65\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5728\u5b89\u88c5\u8f6f\u4ef6\u65f6\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u5939\uff0c\u4f8b\u5982C:\\Python\uff0c\u4e13\u95e8\u7528\u4e8e\u5b58\u653ePython\u53ca\u5176\u76f8\u5173\u5de5\u5177\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u89e3\u51b3Python\u5b89\u88c5\u5230\u4e86\u4e2d\u6587\u8def\u5f84\u4e0b\u7684\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u91cd\u65b0\u5b89\u88c5Python\u5230\u4e00\u4e2a\u82f1\u6587\u8def\u5f84\u4e0b\u3001\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3001\u6216\u8005 [&hellip;]","protected":false},"author":3,"featured_media":1107293,"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\/1107285"}],"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=1107285"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1107285\/revisions"}],"predecessor-version":[{"id":1107294,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1107285\/revisions\/1107294"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1107293"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1107285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1107285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1107285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}