{"id":23221,"date":"2025-05-01T10:12:00","date_gmt":"2025-05-01T02:12:00","guid":{"rendered":"https:\/\/cn.hostease.com\/blog\/?p=23221"},"modified":"2025-01-14T15:22:51","modified_gmt":"2025-01-14T07:22:51","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e6%a3%80%e6%9f%a5python%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/blog\/server\/%e5%a6%82%e4%bd%95%e5%9c%a8linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e6%a3%80%e6%9f%a5python%e7%89%88%e6%9c%ac\/","title":{"rendered":"\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u68c0\u67e5Python\u7248\u672c"},"content":{"rendered":"\n<p>\u6211\u76ee\u524d\u6b63\u5728\u4f7f\u7528<a href=\"https:\/\/cn.hostease.com\" target=\"_blank\" rel=\"noopener\" title=\"Hostease\">Hostease<\/a>\u7684Linux\u670d\u52a1\u5668\u8fdb\u884cPython\u5f00\u53d1\u3002\u9009\u62e9Linux\u670d\u52a1\u5668\u73af\u5883\u662f\u56e0\u4e3a\u5176\u80fd\u591f\u63d0\u4f9b\u7a33\u5b9a\u3001\u5b89\u5168\u7684\u5f00\u53d1\u5e73\u53f0\u3002\u4e0d\u8bba\u662f\u6784\u5efa\u7f51\u7ad9\u3001\u6570\u636e\u5206\u6790\u8fd8\u662f\u673a\u5668\u5b66\u4e60\u5e94\u7528\uff0cHostease\u7684<a href=\"https:\/\/cn.hostease.com\/hkservers.html\" target=\"_blank\" rel=\"noopener\" title=\"\u72ec\u7acb\u670d\u52a1\u5668\">\u72ec\u7acb\u670d\u52a1\u5668<\/a>\u90fd\u80fd\u5145\u5206\u6ee1\u8db3\u9879\u76ee\u9700\u6c42\u3002\u4e3a\u4e86\u786e\u4fdd\u517c\u5bb9\u6027\u4e0e\u7a33\u5b9a\u6027\uff0c\u5728\u5b89\u88c5\u6216\u66f4\u65b0Python\u5305\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u786e\u8ba4Linux\u670d\u52a1\u5668\u4e0a\u7684Python\u7248\u672c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u68c0\u67e5\u6216\u66f4\u65b0Python\u7248\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<p>\u4f7f\u7528Linux\u670d\u52a1\u5668\u7684\u5f00\u53d1\u8005\u9700\u8981\u5177\u5907\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux\u670d\u52a1\u5668<\/li>\n\n\n\n<li>\u8bbf\u95ee\u7ec8\u7aef\u7684\u6743\u9650<\/li>\n\n\n\n<li>\u7ba1\u7406\u5458\u6743\u9650<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u5982\u4f55\u786e\u8ba4Linux\u670d\u52a1\u5668\u4e0a\u5df2\u5b89\u88c5Python<\/h2>\n\n\n\n<p>\u5728\u5f00\u59cb\u68c0\u67e5Python\u7248\u672c\u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u786e\u8ba4Linux\u670d\u52a1\u5668\u4e0a\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5feb\u901f\u9a8c\u8bc1\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u767b\u5f55Linux\u670d\u52a1\u5668\u3002<\/li>\n\n\n\n<li>\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>python3<\/code>\u6210\u529f\u6267\u884c\u547d\u4ee4\u540e\uff0c\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u5c06\u4f1a\u770b\u5230<code>>>><\/code>\u63d0\u793a\u7b26\uff0c\u8868\u793aPython\u89e3\u91ca\u5668\u5df2\u6253\u5f00\u3002\u8f93\u5165<code>exit()<\/code>\u53ef\u9000\u51fa\u89e3\u91ca\u5668\u5e76\u8fd4\u56de\u7ec8\u7aef\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"402\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3-1024x402.webp\" alt=\"python3\" class=\"wp-image-23222\" srcset=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3-1024x402.webp 1024w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3-300x118.webp 300w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3-768x301.webp 768w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3.webp 1068w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728Linux\u670d\u52a1\u5668\u4e0a\u68c0\u67e5Python\u7248\u672c<\/h2>\n\n\n\n<p>\u901a\u8fc7\u4e0a\u8ff0\u64cd\u4f5c\u786e\u8ba4\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u540e\uff0c\u8fd8\u53ef\u4ee5\u68c0\u67e5Python\u7248\u672c\u3002\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\uff0c\u7136\u540e\u6309Enter\u952e\uff1a<code>python --version<\/code>\u6216<code>python3 --version<\/code><\/li>\n\n\n\n<li>\u8f93\u51fa\u7ed3\u679c\u5c06\u663e\u793a\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u786e\u4fdd\u7248\u672c\u7b26\u5408\u60a8\u9879\u76ee\u7684\u9700\u6c42\uff0c\u5c24\u5176\u5728\u9700\u8981\u7279\u5b9aPython\u529f\u80fd\u6216\u5e93\u7684\u60c5\u51b5\u4e0b\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python-1024x357.webp\" alt=\"python\" class=\"wp-image-23223\" srcset=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python-1024x357.webp 1024w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python-300x105.webp 300w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python-768x268.webp 768w, https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python.webp 1057w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528Python\u4ee3\u7801\u68c0\u67e5Linux\u670d\u52a1\u5668\u4e0a\u7684Python\u7248\u672c<\/h2>\n\n\n\n<p>\u5728\u5f00\u53d1\u5e94\u7528\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u52a0\u5165\u7248\u672c\u68c0\u67e5\uff0c\u786e\u4fddPython\u7248\u672c\u7b26\u5408\u9879\u76ee\u8981\u6c42\u3002\u4ee5\u4e0b\u4ee3\u7801\u53ef\u7528\u4e8e\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5Python 3.6\u6216\u66f4\u9ad8\u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import sys\nif not (sys.version_info.major == 3 and sys.version_info.minor >= 6):\n    print(\"\u9700\u8981Python 3.6\u6216\u66f4\u9ad8\u7248\u672c\u3002\")\n    print(f\"\u5f53\u524dPython\u7248\u672c\u4e3a{sys.version_info.major}.{sys.version_info.minor}\")\n    sys.exit(1)<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6bb5\u4ee3\u7801\u9002\u7528\u4e8eLinux\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u4ee3\u7801\u6267\u884c\u524d\u786e\u8ba4Python\u7248\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u6216\u5347\u7ea7Python\u7248\u672c<\/h2>\n\n\n\n<p>\u82e5\u60a8\u7684\u9879\u76ee\u9700\u8981\u7279\u5b9aPython\u7248\u672c\uff0cLinux\u670d\u52a1\u5668\u652f\u6301\u7075\u6d3b\u7684\u7248\u672c\u7ba1\u7406\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5\u4e0e\u5347\u7ea7Python\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5728Linux\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u6216\u5347\u7ea7Python<\/h3>\n\n\n\n<p>\u5728Linux\u670d\u52a1\u5668\u4e0a\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u6216\u5347\u7ea7Python\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f7f\u7528DNF\u5305\u7ba1\u7406\u5668\uff08\u9002\u7528\u4e8eCentOS\u3001Fedora\u7b49\u7cfb\u7edf\uff09\uff1a<\/strong><code>dnf upgrade python3<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528APT\u5305\u7ba1\u7406\u5668\uff08\u9002\u7528\u4e8eDebian\u3001Ubuntu\u7b49\u7cfb\u7edf\uff09\uff1a<\/strong><code>apt upgrade python3<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u9009\u62e9Linux\u670d\u52a1\u5668\u8fdb\u884cPython\u5f00\u53d1\uff1f<\/h2>\n\n\n\n<p>Linux\u4e0d\u4ec5\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684<a href=\"https:\/\/cn.hostease.com\/shared-hosting.html\" target=\"_blank\" rel=\"noopener\" title=\"\u865a\u62df\u4e3b\u673a\">\u865a\u62df\u4e3b\u673a<\/a>\u3001<a href=\"https:\/\/cn.hostease.com\/vps.html\" target=\"_blank\" rel=\"noopener\" title=\"VPS\u4e91\u4e3b\u673a\">VPS\u4e91\u4e3b\u673a<\/a>\u548c\u72ec\u7acb\u670d\u52a1\u5668\uff0c\u8fd8\u652f\u6301\u4e30\u5bcc\u7684\u5f00\u53d1\u73af\u5883\u914d\u7f6e\uff0c\u4f7f\u5176\u6210\u4e3aPython\u5f00\u53d1\u7684\u7406\u60f3\u5e73\u53f0\u3002\u4ee5\u4e0b\u662f\u9009\u62e9Linux\u7684\u51e0\u4e2a\u5173\u952e\u539f\u56e0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9ad8\u7a33\u5b9a\u6027\u548c\u517c\u5bb9\u6027\uff1aLinux\u670d\u52a1\u5668\u652f\u6301\u591a\u4e2aPython\u7248\u672c\uff0c\u6ee1\u8db3\u4ece\u57fa\u7840\u5f00\u53d1\u5230\u590d\u6742\u5e94\u7528\u7684\u591a\u6837\u9700\u6c42\u3002<\/li>\n\n\n\n<li>\u5b89\u5168\u53ef\u9760\u7684\u73af\u5883\uff1aLinux\u63d0\u4f9b\u5168\u9762\u7684\u5b89\u5168\u4fdd\u62a4\uff0c\u8ba9\u60a8\u7684\u5f00\u53d1\u5de5\u4f5c\u4e13\u6ce8\u4e8e\u529f\u80fd\u5b9e\u73b0\u800c\u65e0\u540e\u987e\u4e4b\u5fe7\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u638c\u63e1\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e2d\u68c0\u67e5Python\u7248\u672c\u662fPython\u5f00\u53d1\u8005\u7684\u57fa\u672c\u6280\u80fd\u3002\u901a\u8fc7\u672c\u6307\u5357\u63d0\u4f9b\u7684\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728Linux\u670d\u52a1\u5668\u4e0a\u5feb\u901f\u786e\u8ba4Python\u7248\u672c\uff0c\u4ee5\u786e\u4fdd\u9879\u76ee\u7684\u517c\u5bb9\u6027\u4e0e\u7a33\u5b9a\u6027\uff0c\u4e3a\u5f00\u53d1\u5de5\u4f5c\u5960\u5b9a\u575a\u5b9e\u57fa\u7840\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u68c0\u67e5\u548c\u786e\u8ba4\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u5305\u62ec\u5728\u7ec8\u7aef\u9a8c\u8bc1Python\u7248\u672c\u7684\u65b9\u6cd5\u4ee5\u53ca\u4f7f\u7528\u4ee3\u7801\u68c0\u6d4b\u7248\u672c\u7684\u6280\u5de7\u3002\u540c\u65f6\uff0c\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u5728Linux\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u6216\u5347\u7ea7Python\u7248\u672c\u7684\u6307\u5357\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u786e\u4fddPython\u73af\u5883\u4e0e\u9879\u76ee\u9700\u6c42\u517c\u5bb9\u3002\u901a\u8fc7\u9009\u62e9Hostease\u63d0\u4f9b\u7684Linux\u670d\u52a1\u5668\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4eab\u53d7\u9ad8\u6027\u80fd\u3001\u7a33\u5b9a\u3001\u5b89\u5168\u7684\u5f00\u53d1\u73af\u5883\uff0c\u8f7b\u677e\u5b8c\u6210\u4ece\u57fa\u7840\u5f00\u53d1\u5230\u590d\u6742\u5e94\u7528\u7684\u6784\u5efa\u5de5\u4f5c\u3002<\/p>\n","protected":false},"author":9,"featured_media":23222,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[493,1006,2516,243],"class_list":["post-23221","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-hostease","tag-linux","tag-python","tag-vps"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2025\/01\/python3.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/23221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/comments?post=23221"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/23221\/revisions"}],"predecessor-version":[{"id":23224,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/23221\/revisions\/23224"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media\/23222"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media?parent=23221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/categories?post=23221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/tags?post=23221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}