{"id":1044639,"date":"2024-12-31T13:16:24","date_gmt":"2024-12-31T05:16:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1044639.html"},"modified":"2024-12-31T13:16:27","modified_gmt":"2024-12-31T05:16:27","slug":"python%e5%ba%93%e5%a6%82%e4%bd%95%e6%b5%8b%e8%af%95%e6%98%af%e5%90%a6%e5%ae%89%e8%a3%85%e5%8c%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1044639.html","title":{"rendered":"python\u5e93\u5982\u4f55\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u5305"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/c369a271-2f85-4eb3-9096-7a7daa09ea65.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5e93\u5982\u4f55\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u5305\" \/><\/p>\n<p><p> <strong>Python\u5e93\u5982\u4f55\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u5305\uff1a\u4f7f\u7528try-except\u8bed\u53e5\u3001\u4f7f\u7528pip\u547d\u4ee4\u3001\u4f7f\u7528pkg_resources\u6a21\u5757<\/strong>\u3002\u4e3a\u4e86\u786e\u4fdd\u4ee3\u7801\u7684\u5065\u58ee\u6027\u548c\u53ef\u79fb\u690d\u6027\uff0c\u5f00\u53d1\u8005\u5e38\u5e38\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5\u67d0\u4e9bPython\u5e93\u3002\u672c\u6587\u5c06\u91cd\u70b9\u4ecb\u7ecd\u4e09\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u7684\uff0c\u5e76\u8be6\u7ec6\u8bb2\u89e3\u4f7f\u7528try-except\u8bed\u53e5\u8fdb\u884c\u68c0\u67e5\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528try-except\u8bed\u53e5\u662f\u6700\u7b80\u5355\u548c\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u5b83\u901a\u8fc7\u5c1d\u8bd5\u5bfc\u5165\u5e93\uff0c\u5982\u679c\u5bfc\u5165\u5931\u8d25\uff0c\u5219\u6355\u83b7ImportError\u5f02\u5e38\uff0c\u8fdb\u800c\u5f97\u77e5\u5e93\u672a\u5b89\u88c5\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    import numpy<\/p>\n<p>except ImportError:<\/p>\n<p>    print(&quot;Numpy is not installed&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;Numpy is installed&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0ctry\u5757\u5c1d\u8bd5\u5bfc\u5165numpy\u5e93\u3002\u5982\u679cnumpy\u672a\u5b89\u88c5\uff0c\u7a0b\u5e8f\u5c06\u8df3\u8f6c\u5230except\u5757\u5e76\u6253\u5370\u51fa&quot;Numpy is not installed&quot;\u3002\u5426\u5219\uff0c\u5b83\u5c06\u6267\u884celse\u5757\u5e76\u6253\u5370&quot;Numpy is installed&quot;\u3002<\/p>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001\u4f7f\u7528try-except\u8bed\u53e5<\/h3>\n<\/p>\n<p><h4>1. \u7b80\u5355\u7684try-except\u793a\u4f8b<\/h4>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0ctry-except\u8bed\u53e5\u662f\u4e00\u79cd\u57fa\u7840\u7684\u5f02\u5e38\u5904\u7406\u673a\u5236\u3002\u5b83\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6355\u83b7\u5e93\u672a\u5b89\u88c5\u7684\u60c5\u51b5\uff0c\u8fd8\u80fd\u5904\u7406\u5176\u4ed6\u7c7b\u578b\u7684\u5f02\u5e38\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u66f4\u8be6\u7ec6\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528try-except\u6765\u68c0\u67e5\u591a\u4e2a\u5e93\u662f\u5426\u5df2\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">libraries = [&#39;numpy&#39;, &#39;pandas&#39;, &#39;matplotlib&#39;]<\/p>\n<p>for lib in libraries:<\/p>\n<p>    try:<\/p>\n<p>        exec(f&quot;import {lib}&quot;)<\/p>\n<p>    except ImportError:<\/p>\n<p>        print(f&quot;{lib} is not installed&quot;)<\/p>\n<p>    else:<\/p>\n<p>        print(f&quot;{lib} is installed&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u6765\u68c0\u67e5\u591a\u4e2a\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002exec\u51fd\u6570\u52a8\u6001\u6267\u884c\u5b57\u7b26\u4e32\u4e2d\u7684Python\u4ee3\u7801\uff0c\u56e0\u6b64\u53ef\u4ee5\u7528\u6765\u5bfc\u5165\u5e93\u3002\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u7075\u6d3b\uff0c\u4f46\u4e5f\u6709\u4e00\u5b9a\u7684\u5b89\u5168\u9690\u60a3\uff0c\u56e0\u4e3aexec\u51fd\u6570\u4f1a\u6267\u884c\u4efb\u4f55\u4f20\u5165\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>2. \u6355\u83b7\u7279\u5b9a\u7684\u5f02\u5e38<\/h4>\n<\/p>\n<p><p>\u6709\u65f6\u6211\u4eec\u4e0d\u4ec5\u4ec5\u9700\u8981\u77e5\u9053\u5e93\u662f\u5426\u5df2\u5b89\u88c5\uff0c\u8fd8\u60f3\u83b7\u5f97\u66f4\u591a\u7684\u9519\u8bef\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u67d0\u4e9b\u5e93\u53ef\u80fd\u6709\u4f9d\u8d56\u5173\u7cfb\uff0c\u5982\u679c\u4f9d\u8d56\u5e93\u672a\u5b89\u88c5\uff0c\u4e5f\u4f1a\u5bfc\u81f4ImportError\u3002\u6211\u4eec\u53ef\u4ee5\u6355\u83b7\u5e76\u5904\u7406\u7279\u5b9a\u7684\u5f02\u5e38\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    import some_library<\/p>\n<p>except ImportError as e:<\/p>\n<p>    print(f&quot;Error: {e}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cImportError\u7684\u5177\u4f53\u4fe1\u606f\u5c06\u5b58\u50a8\u5728\u53d8\u91cfe\u4e2d\uff0c\u5e76\u88ab\u6253\u5370\u51fa\u6765\u3002\u8fd9\u79cd\u65b9\u6cd5\u6709\u52a9\u4e8e\u66f4\u597d\u5730\u8c03\u8bd5\u548c\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528pip\u547d\u4ee4<\/h3>\n<\/p>\n<p><h4>1. pip list<\/h4>\n<\/p>\n<p><p>pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u5b89\u88c5\u3001\u66f4\u65b0\u548c\u5378\u8f7d\u5e93\u3002\u4f7f\u7528pip list\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\u3002\u901a\u8fc7\u68c0\u67e5\u8f93\u51fa\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u5b9a\u67d0\u4e2a\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<p>def is_installed(package):<\/p>\n<p>    installed_packages = subprocess.check_output([&#39;pip&#39;, &#39;list&#39;]).decode(&#39;utf-8&#39;)<\/p>\n<p>    return package in installed_packages<\/p>\n<p>if is_installed(&#39;numpy&#39;):<\/p>\n<p>    print(&#39;Numpy is installed&#39;)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Numpy is not installed&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528subprocess\u6a21\u5757\u6267\u884cpip list\u547d\u4ee4\uff0c\u5e76\u5c06\u8f93\u51fa\u89e3\u7801\u6210\u5b57\u7b26\u4e32\u3002\u7136\u540e\uff0c\u6211\u4eec\u68c0\u67e5\u8f93\u51fa\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5e93\u540d\u3002<\/p>\n<\/p>\n<p><h4>2. pip show<\/h4>\n<\/p>\n<p><p>pip show\u547d\u4ee4\u663e\u793a\u6307\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u5982\u679c\u5e93\u672a\u5b89\u88c5\uff0cpip show\u5c06\u8fd4\u56de\u975e\u96f6\u9000\u51fa\u72b6\u6001\u3002\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\u6765\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<p>def is_installed(package):<\/p>\n<p>    try:<\/p>\n<p>        subprocess.check_call([&#39;pip&#39;, &#39;show&#39;, package])<\/p>\n<p>        return True<\/p>\n<p>    except subprocess.CalledProcessError:<\/p>\n<p>        return False<\/p>\n<p>if is_installed(&#39;numpy&#39;):<\/p>\n<p>    print(&#39;Numpy is installed&#39;)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Numpy is not installed&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0csubprocess.check_call\u51fd\u6570\u6267\u884cpip show\u547d\u4ee4\u3002\u5982\u679c\u547d\u4ee4\u6210\u529f\u6267\u884c\uff08\u5373\u5e93\u5df2\u5b89\u88c5\uff09\uff0c\u51fd\u6570\u5c06\u8fd4\u56deTrue\u3002\u5426\u5219\uff0c\u5c06\u6355\u83b7CalledProcessError\u5f02\u5e38\uff0c\u5e76\u8fd4\u56deFalse\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528pkg_resources\u6a21\u5757<\/h3>\n<\/p>\n<p><p>pkg_resources\u662fsetuptools\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e9b\u6709\u7528\u7684\u5de5\u5177\u6765\u7ba1\u7406Python\u5305\u3002\u901a\u8fc7pkg_resources\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u4ee5\u53ca\u5176\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h4>1. \u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>pkg_resources\u63d0\u4f9b\u4e86\u4e00\u4e2arequire\u51fd\u6570\uff0c\u7528\u4e8e\u68c0\u67e5\u6307\u5b9a\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679c\u5e93\u672a\u5b89\u88c5\u6216\u7248\u672c\u4e0d\u5339\u914d\uff0c\u5c06\u5f15\u53d1DistributionNotFound\u6216VersionConflict\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pkg_resources<\/p>\n<p>def is_installed(package):<\/p>\n<p>    try:<\/p>\n<p>        pkg_resources.require(package)<\/p>\n<p>        return True<\/p>\n<p>    except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):<\/p>\n<p>        return False<\/p>\n<p>if is_installed(&#39;numpy&#39;):<\/p>\n<p>    print(&#39;Numpy is installed&#39;)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Numpy is not installed&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528pkg_resources.require\u51fd\u6570\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679c\u5e93\u672a\u5b89\u88c5\u6216\u7248\u672c\u4e0d\u5339\u914d\uff0c\u5c06\u6355\u83b7\u5f02\u5e38\u5e76\u8fd4\u56deFalse\u3002<\/p>\n<\/p>\n<p><h4>2. \u83b7\u53d6\u5e93\u7684\u7248\u672c\u4fe1\u606f<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\uff0cpkg_resources\u8fd8\u53ef\u4ee5\u83b7\u53d6\u5df2\u5b89\u88c5\u5e93\u7684\u7248\u672c\u4fe1\u606f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pkg_resources<\/p>\n<p>def get_version(package):<\/p>\n<p>    try:<\/p>\n<p>        dist = pkg_resources.get_distribution(package)<\/p>\n<p>        return dist.version<\/p>\n<p>    except pkg_resources.DistributionNotFound:<\/p>\n<p>        return None<\/p>\n<p>version = get_version(&#39;numpy&#39;)<\/p>\n<p>if version:<\/p>\n<p>    print(f&#39;Numpy version {version} is installed&#39;)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Numpy is not installed&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528pkg_resources.get_distribution\u51fd\u6570\u83b7\u53d6\u6307\u5b9a\u5e93\u7684\u5206\u53d1\u4fe1\u606f\uff0c\u5e76\u4ece\u4e2d\u63d0\u53d6\u7248\u672c\u53f7\u3002\u5982\u679c\u5e93\u672a\u5b89\u88c5\uff0c\u5c06\u6355\u83b7DistributionNotFound\u5f02\u5e38\uff0c\u5e76\u8fd4\u56deNone\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u4e09\u79cd\u6d4b\u8bd5Python\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u7684\u65b9\u6cd5\uff1a\u4f7f\u7528try-except\u8bed\u53e5\u3001\u4f7f\u7528pip\u547d\u4ee4\u4ee5\u53ca\u4f7f\u7528pkg_resources\u6a21\u5757\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>try-except\u8bed\u53e5<\/strong>\uff1a\u7b80\u5355\u76f4\u63a5\uff0c\u9002\u5408\u5728\u4ee3\u7801\u4e2d\u5feb\u901f\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002<\/li>\n<li><strong>pip\u547d\u4ee4<\/strong>\uff1a\u529f\u80fd\u5f3a\u5927\uff0c\u9002\u5408\u4ece\u547d\u4ee4\u884c\u6216\u811a\u672c\u4e2d\u68c0\u67e5\u5e93\u662f\u5426\u5df2\u5b89\u88c5\u3002<\/li>\n<li><strong>pkg_resources\u6a21\u5757<\/strong>\uff1a\u63d0\u4f9b\u66f4\u591a\u529f\u80fd\uff0c\u9002\u5408\u9700\u8981\u83b7\u53d6\u5e93\u7248\u672c\u4fe1\u606f\u6216\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406Python\u9879\u76ee\u4e2d\u7684\u4f9d\u8d56\u5e93\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u5065\u58ee\u6027\u548c\u53ef\u79fb\u690d\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u8ba4\u6211\u7684Python\u73af\u5883\u4e2d\u662f\u5426\u5df2\u5b89\u88c5\u7279\u5b9a\u7684\u5e93\uff1f<\/strong><br \/>\u8981\u786e\u8ba4\u7279\u5b9a\u7684Python\u5e93\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>pip show \u5e93\u540d<\/code>\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u60f3\u8981\u68c0\u67e5<code>numpy<\/code>\u662f\u5426\u5b89\u88c5\uff0c\u53ef\u4ee5\u8f93\u5165<code>pip show numpy<\/code>\u3002\u5982\u679c\u5e93\u5df2\u5b89\u88c5\uff0c\u5c06\u663e\u793a\u5176\u7248\u672c\u548c\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u5219\u4e0d\u4f1a\u663e\u793a\u4efb\u4f55\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u53d1\u73b0\u67d0\u4e2a\u5e93\u6ca1\u6709\u5b89\u88c5\uff0c\u8be5\u5982\u4f55\u5b89\u88c5\u5b83\uff1f<\/strong><br \/>\u5982\u679c\u53d1\u73b0\u67d0\u4e2a\u5e93\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install \u5e93\u540d<\/code>\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u5b89\u88c5<code>pandas<\/code>\u53ef\u4ee5\u8f93\u5165<code>pip install pandas<\/code>\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528<code>pip show pandas<\/code>\u6765\u786e\u8ba4\u5e93\u662f\u5426\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5728\u4f7f\u7528Python\u5e93\u65f6\uff0c\u5982\u4f55\u5904\u7406\u53ef\u80fd\u7684\u4f9d\u8d56\u6027\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u5b89\u88c5\u67d0\u4e9b\u5e93\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4f9d\u8d56\u6027\u95ee\u9898\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528<code>pip install \u5e93\u540d<\/code>\u547d\u4ee4\u65f6\uff0cpip\u4f1a\u81ea\u52a8\u5904\u7406\u5927\u90e8\u5206\u4f9d\u8d56\u5173\u7cfb\u3002\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u53ef\u4ee5\u624b\u52a8\u5b89\u88c5\u7f3a\u5931\u7684\u4f9d\u8d56\u5e93\uff0c\u6216\u8005\u53c2\u8003\u5e93\u7684\u5b98\u65b9\u6587\u6863\u83b7\u53d6\u66f4\u591a\u89e3\u51b3\u65b9\u6848\u3002\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u547d\u4ee4\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u6587\u4ef6\u6279\u91cf\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5e93\u5982\u4f55\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u5305\uff1a\u4f7f\u7528try-except\u8bed\u53e5\u3001\u4f7f\u7528pip\u547d\u4ee4\u3001\u4f7f\u7528pkg_resources [&hellip;]","protected":false},"author":3,"featured_media":1044653,"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\/1044639"}],"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=1044639"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1044639\/revisions"}],"predecessor-version":[{"id":1044656,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1044639\/revisions\/1044656"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1044653"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1044639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1044639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1044639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}