{"id":972754,"date":"2024-12-27T05:51:15","date_gmt":"2024-12-26T21:51:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/972754.html"},"modified":"2024-12-27T05:51:17","modified_gmt":"2024-12-26T21:51:17","slug":"python%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85distutils%e5%8c%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/972754.html","title":{"rendered":"python\u5982\u4f55\u5b89\u88c5distutils\u5305"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24195255\/13ab8e61-0060-49d3-9cb2-cf1addbbeaa6.webp\" alt=\"python\u5982\u4f55\u5b89\u88c5distutils\u5305\" \/><\/p>\n<p><p> \u8981\u5728Python\u4e2d\u5b89\u88c5<code>distutils<\/code>\u5305\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5b9e\u73b0\uff1a<strong>\u68c0\u67e5\u5f53\u524dPython\u7248\u672c\u3001\u4f7f\u7528\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177\u3001\u786e\u4fddPython\u73af\u5883\u914d\u7f6e\u6b63\u786e<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u68c0\u67e5\u5f53\u524dPython\u7248\u672c<\/strong>\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5927\u591a\u6570\u73b0\u4ee3Python\u7248\u672c\u5df2\u7ecf\u81ea\u5e26<code>distutils<\/code>\u5305\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u68c0\u67e5\u5e76\u5b89\u88c5<code>distutils<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u68c0\u67e5\u5f53\u524dPython\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5927\u591a\u6570Python\u7248\u672c\u9ed8\u8ba4\u5df2\u5305\u542b<code>distutils<\/code>\u6a21\u5757\uff0c\u56e0\u6b64\u5728\u5b89\u88c5\u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u68c0\u67e5\u4f60\u7684Python\u7248\u672c\u662f\u5426\u5df2\u7ecf\u81ea\u5e26\u6b64\u6a21\u5757\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fdb\u884c\u68c0\u67e5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u7ec8\u7aef\uff08Linux\u6216macOS\uff09\u6216\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5<code>distutils<\/code>\u6a21\u5757\u662f\u5426\u5b58\u5728\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import distutils<\/p>\n<p>print(distutils.__file__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4e0d\u51fa\u73b0\u9519\u8bef\uff0c\u5e76\u4e14\u8f93\u51fa\u663e\u793a\u4e86\u6a21\u5757\u7684\u6587\u4ef6\u8def\u5f84\uff0c\u5219\u8bf4\u660e<code>distutils<\/code>\u5df2\u7ecf\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u5982\u679c<code>distutils<\/code>\u672a\u5b89\u88c5\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u4f60\u7684Python\u5b89\u88c5\u4e0d\u5b8c\u6574\u6216\u7248\u672c\u8fc7\u65e7\u3002\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177\u8fdb\u884c\u5b89\u88c5\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5<code>distutils<\/code>\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5728Windows\u4e0a\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c<code>distutils<\/code>\u901a\u5e38\u968fPython\u5b89\u88c5\u5305\u4e00\u8d77\u63d0\u4f9b\u3002\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5Python\uff0c\u786e\u4fdd\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u5e76\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\uff0c\u786e\u4fdd\u52fe\u9009\u4e86\u201cDistutils\u201d\u9009\u9879\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5728macOS\u4e0a\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>macOS\u901a\u5e38\u81ea\u5e26Python\uff0c\u4f46\u53ef\u80fd\u7248\u672c\u8f83\u65e7\u3002\u53ef\u4ee5\u901a\u8fc7Homebrew\u66f4\u65b0Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew update<\/p>\n<p>brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u66f4\u65b0\u540e\uff0c\u91cd\u65b0\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u4e86<code>distutils<\/code>\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5728Linux\u4e0a\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5728Linux\u53d1\u884c\u7248\u4e2d\uff0c<code>distutils<\/code>\u901a\u5e38\u901a\u8fc7<code>python3-distutils<\/code>\u5305\u63d0\u4f9b\u3002\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Debian\/Ubuntu<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python3-distutils<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Fedora<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf install python3-distutils<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Arch Linux<\/strong><\/p>\n<\/p>\n<p><p><code>distutils<\/code>\u901a\u5e38\u5305\u542b\u5728<code>python<\/code>\u5305\u4e2d\uff0c\u66f4\u65b0Python\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u786e\u4fddPython\u73af\u5883\u914d\u7f6e\u6b63\u786e<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u73af\u5883\u914d\u7f6e\u6b63\u786e\uff0c\u53ef\u80fd\u9700\u8981\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\uff0c\u5c24\u5176\u662f\u5728Windows\u7cfb\u7edf\u4e0a\u3002\u786e\u4fddPython\u7684\u5b89\u88c5\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u53d8\u91cf\u4e2d\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u4e2d\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u907f\u514d\u5305\u7ba1\u7406\u95ee\u9898\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u5e76\u5728\u5176\u4e2d\u4f7f\u7528<code>distutils<\/code>\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Windows<\/strong><\/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><strong>Linux\/macOS<\/strong><\/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<\/li>\n<li>\n<p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>distutils<\/code>\uff0c\u65e0\u9700\u989d\u5916\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4f7f\u7528pip\u8fdb\u884c\u5305\u7ba1\u7406<\/h3>\n<\/p>\n<p><p>\u867d\u7136<code>distutils<\/code>\u4e0d\u901a\u8fc7<code>pip<\/code>\u8fdb\u884c\u5b89\u88c5\uff0c\u4f46\u786e\u4fdd<code>pip<\/code>\u662f\u6700\u65b0\u7248\u672c\u5bf9\u4e8e\u5305\u7ba1\u7406\u81f3\u5173\u91cd\u8981\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u901a\u5e38\u53ef\u4ee5\u89e3\u51b3\u5927\u591a\u6570\u4e0e<code>distutils<\/code>\u76f8\u5173\u7684\u95ee\u9898\u3002\u786e\u4fdd\u7cfb\u7edf\u7684Python\u73af\u5883\u914d\u7f6e\u6b63\u786e\uff0c\u5e76\u5728\u9700\u8981\u65f6\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406Python\u9879\u76ee\u4e2d\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u7684Python\u73af\u5883\u4e2d\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86distutils\u5305\uff1f<\/strong><br \/>\u8981\u68c0\u67e5distutils\u662f\u5426\u5df2\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-bash\">python -m pip show distutils\n<\/code><\/pre>\n<p>\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230\u76f8\u5173\u7684\u5305\u4fe1\u606f\u3002\u5982\u679c\u672a\u663e\u793a\u4efb\u4f55\u4fe1\u606f\uff0c\u5219\u8868\u793a\u672a\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5distutils\u7684\u5177\u4f53\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728Windows\u4e0a\uff0cdistutils\u901a\u5e38\u4f1a\u968fPython\u5b89\u88c5\u5305\u4e00\u8d77\u5b89\u88c5\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7dPython\u7684\u5b89\u88c5\u7a0b\u5e8f\u5e76\u9009\u62e9\u201c\u4fee\u590d\u201d\u9009\u9879\u6765\u6dfb\u52a0\u5b83\u3002\u5728Linux\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff0c\u5982apt\u6216yum\uff0c\u8fd0\u884c\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo apt-get install python3-distutils\n<\/code><\/pre>\n<p>\u5728macOS\u4e0a\uff0c\u4f7f\u7528Homebrew\u5b89\u88c5Python\u65f6\uff0cdistutils\u4e5f\u4f1a\u81ea\u52a8\u5305\u62ec\u5728\u5185\u3002<\/p>\n<p><strong>\u5982\u679c\u5b89\u88c5distutils\u5305\u65f6\u9047\u5230\u9519\u8bef\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u9047\u5230\u9519\u8bef\u65f6\uff0c\u9996\u5148\u786e\u4fdd\u60a8\u7684Python\u548cpip\u7248\u672c\u662f\u6700\u65b0\u7684\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0pip\uff1a  <\/p>\n<pre><code class=\"language-bash\">python -m pip install --upgrade pip\n<\/code><\/pre>\n<p>\u5982\u679c\u4ecd\u7136\u5b58\u5728\u95ee\u9898\uff0c\u68c0\u67e5\u60a8\u7684\u7f51\u7edc\u8fde\u63a5\u6216\u5c1d\u8bd5\u4f7f\u7528\u4e0d\u540c\u7684\u6e90\u8fdb\u884c\u5b89\u88c5\uff0c\u6bd4\u5982\u6e05\u534e\u5927\u5b66\u7684\u955c\u50cf\u6e90\uff1a  <\/p>\n<pre><code class=\"language-bash\">pip install distutils -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\n<\/code><\/pre>\n<p>\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u53ef\u4ee5\u67e5\u770b\u9519\u8bef\u4fe1\u606f\u5e76\u641c\u7d22\u76f8\u5173\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u6216\u8005\u5728\u5f00\u53d1\u8005\u793e\u533a\u5bfb\u6c42\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u5b89\u88c5distutils\u5305\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5b9e\u73b0\uff1a\u68c0\u67e5\u5f53\u524dPython\u7248\u672c\u3001\u4f7f\u7528\u7cfb\u7edf\u7684\u5305 [&hellip;]","protected":false},"author":3,"featured_media":972757,"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\/972754"}],"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=972754"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/972754\/revisions"}],"predecessor-version":[{"id":972759,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/972754\/revisions\/972759"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/972757"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=972754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=972754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=972754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}