{"id":1170609,"date":"2025-01-15T16:24:42","date_gmt":"2025-01-15T08:24:42","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1170609.html"},"modified":"2025-01-15T16:24:45","modified_gmt":"2025-01-15T08:24:45","slug":"%e5%a6%82%e4%bd%95%e5%8d%b8%e8%bd%bdpython%e5%ae%89%e8%a3%85%e7%9a%84%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1170609.html","title":{"rendered":"\u5982\u4f55\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26073212\/4662e0aa-dba4-4a2a-9164-5d255696cead.webp\" alt=\"\u5982\u4f55\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93<\/strong>\uff1a\u53ef\u4ee5\u901a\u8fc7pip\u5de5\u5177\u3001\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\u3001\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u7b49\u65b9\u6cd5\u6765\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93\u3002<strong>\u4f7f\u7528pip\u5de5\u5177<\/strong>\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u65b9\u4fbf\u5feb\u6377\u5730\u7ba1\u7406Python\u5e93\u3002\u8981\u8be6\u7ec6\u63cf\u8ff0\u7684\u662f\uff0c\u4f7f\u7528pip\u5de5\u5177\u5378\u8f7dPython\u5e93\u7684\u5177\u4f53\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5de5\u5177\u5378\u8f7dPython\u5e93\u65f6\uff0c\u9996\u5148\u9700\u8981\u77e5\u9053\u4f60\u8981\u5378\u8f7d\u7684\u5e93\u7684\u540d\u79f0\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall \u5e93\u540d<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8981\u5378\u8f7d\u540d\u4e3a<code>requests<\/code>\u7684\u5e93\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4f1a\u63d0\u793a\u4f60\u786e\u8ba4\u662f\u5426\u8981\u5378\u8f7d\u8be5\u5e93\uff0c\u8f93\u5165<code>y<\/code>\u5e76\u56de\u8f66\u5373\u53ef\u5b8c\u6210\u5378\u8f7d\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001PIP\u5de5\u5177\u5378\u8f7d<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u4f7f\u7528pip\u5378\u8f7d\u5355\u4e2a\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5de5\u5177\u5378\u8f7d\u5355\u4e2aPython\u5e93\u662f\u6700\u57fa\u672c\u548c\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u4f60\u53ea\u9700\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall \u5e93\u540d<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u5378\u8f7d\u540d\u4e3a<code>numpy<\/code>\u7684\u5e93\uff0c\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cpip\u4f1a\u5217\u51fa\u5c06\u8981\u5220\u9664\u7684\u6587\u4ef6\uff0c\u5e76\u63d0\u793a\u4f60\u786e\u8ba4\u5378\u8f7d\u3002\u8f93\u5165<code>y<\/code>\u540e\uff0cpip\u5c06\u4f1a\u5220\u9664\u76f8\u5173\u7684\u6587\u4ef6\u548c\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<p><p><strong>2\u3001\u6279\u91cf\u5378\u8f7d\u591a\u4e2a\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u6709\u591a\u4e2a\u5e93\u9700\u8981\u5378\u8f7d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5e93\u540d\u79f0\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u6279\u91cf\u5378\u8f7d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>requirements.txt<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u6587\u4ef6\u4e2d\u5217\u51fa\u4f60\u60f3\u8981\u5378\u8f7d\u7684\u5e93\u540d\u79f0\uff0c\u6bcf\u884c\u4e00\u4e2a\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code>numpy<\/p>\n<p>pandas<\/p>\n<p>matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\uff0cpip\u4f1a\u6309\u7167\u6587\u4ef6\u4e2d\u7684\u5e93\u540d\u79f0\u4f9d\u6b21\u5378\u8f7d\u76f8\u5e94\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u627e\u5230\u5e93\u6587\u4ef6\u6240\u5728\u76ee\u5f55<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6\u6765\u5378\u8f7d\u5e93\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u624b\u52a8\u5b89\u88c5\u7684\u5e93\u6216\u65e0\u6cd5\u901a\u8fc7pip\u5de5\u5177\u5378\u8f7d\u7684\u5e93\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u627e\u5230\u5e93\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u5e93\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import \u5e93\u540d<\/p>\n<p>print(\u5e93\u540d.__file__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u67e5\u770b<code>numpy<\/code>\u5e93\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy<\/p>\n<p>print(numpy.__file__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f1a\u8f93\u51fa\u5e93\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4f8b\u5982\uff1a<code>\/path\/to\/python\/lib\/python3.x\/site-packages\/numpy<\/code>\u3002<\/p>\n<\/p>\n<p><p><strong>2\u3001\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u627e\u5230\u5e93\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6587\u4ef6\u7ba1\u7406\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5220\u9664<code>numpy<\/code>\u5e93\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">rm -rf \/path\/to\/python\/lib\/python3.x\/site-packages\/numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bf7\u6ce8\u610f\uff0c\u4f7f\u7528\u6b64\u65b9\u6cd5\u9700\u8981\u975e\u5e38\u5c0f\u5fc3\uff0c\u56e0\u4e3a\u624b\u52a8\u5220\u9664\u6587\u4ef6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u610f\u5916\u7684\u95ee\u9898\u6216\u635f\u574f\u5176\u4ed6\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u521b\u5efa\u548c\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662f\u4e00\u4e2a\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u5b83\u5141\u8bb8\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u7ba1\u7406\u591a\u4e2aPython\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u800c\u4e0d\u4f1a\u53d1\u751f\u51b2\u7a81\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u5730\u7ba1\u7406\u548c\u5378\u8f7d\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>virtualenv<\/code>\u6216<code>venv<\/code>\u5de5\u5177\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f7f\u7528<code>venv<\/code>\u5de5\u5177\u521b\u5efa\u548c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p>source myenv\/bin\/activate  # \u5728Windows\u4e0a\u4f7f\u7528 myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>2\u3001\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u5378\u8f7d\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u50cf\u5728\u5168\u5c40Python\u73af\u5883\u4e2d\u4e00\u6837\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5\u548c\u5378\u8f7d\u5e93\u3002\u4f8b\u5982\uff0c\u5b89\u88c5<code>requests<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5378\u8f7d<code>requests<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u4e2d\u7684\u6240\u6709\u5e93\u90fd\u662f\u72ec\u7acb\u7684\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u4e2d\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5378\u8f7d<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u4f7f\u7528conda\u5378\u8f7d\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4f7f\u7528Anaconda\u6216Miniconda\u6765\u7ba1\u7406Python\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>conda<\/code>\u5de5\u5177\u6765\u5378\u8f7d\u5e93\u3002\u9996\u5148\uff0c\u6fc0\u6d3b\u4f60\u8981\u64cd\u4f5c\u7684\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5378\u8f7d\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove \u5e93\u540d<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5378\u8f7d<code>numpy<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>2\u3001\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0cPython\u5e93\u53ef\u80fd\u662f\u901a\u8fc7\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\uff08\u5982apt\u3001yum\u3001brew\u7b49\uff09\u5b89\u88c5\u7684\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684\u5305\u7ba1\u7406\u5668\u6765\u5378\u8f7d\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5728Debian\/Ubuntu\u7cfb\u7edf\u4e0a\u4f7f\u7528<code>apt<\/code>\u5378\u8f7d\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get remove python3-numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Red Hat\/CentOS\u7cfb\u7edf\u4e0a\u4f7f\u7528<code>yum<\/code>\u5378\u8f7d\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum remove python3-numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728macOS\u4e0a\u4f7f\u7528<code>brew<\/code>\u5378\u8f7d\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew uninstall numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6ce8\u610f\u4e8b\u9879\u548c\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u5907\u4efd\u548c\u8bb0\u5f55<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5378\u8f7d\u5e93\u4e4b\u524d\uff0c\u7279\u522b\u662f\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u5efa\u8bae\u5148\u5907\u4efd\u5f53\u524d\u73af\u5883\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u5f53\u524d\u73af\u5883\u7684\u4f9d\u8d56\u5173\u7cfb\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip freeze &gt; requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c\u5982\u679c\u5378\u8f7d\u67d0\u4e2a\u5e93\u5bfc\u81f4\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u6062\u590d\u5230\u539f\u6765\u7684\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><p><strong>2\u3001\u907f\u514d\u51b2\u7a81<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5378\u8f7d\u5e93\u65f6\uff0c\u7279\u522b\u662f\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6\u65f6\uff0c\u8981\u5c0f\u5fc3\u907f\u514d\u5220\u9664\u5176\u4ed6\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u5efa\u8bae\u4f7f\u7528pip\u5de5\u5177\u6216\u5305\u7ba1\u7406\u5668\u6765\u5378\u8f7d\u5e93\uff0c\u4ee5\u786e\u4fdd\u4f9d\u8d56\u5173\u7cfb\u7684\u6b63\u786e\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p><strong>3\u3001\u5b9a\u671f\u6e05\u7406<\/strong><\/p>\n<\/p>\n<p><p>\u5b9a\u671f\u6e05\u7406\u4e0d\u518d\u4f7f\u7528\u7684\u5e93\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301Python\u73af\u5883\u7684\u6574\u6d01\u548c\u9ad8\u6548\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u6216\u5305\u7ba1\u7406\u5668\u6765\u5217\u51fa\u5f53\u524d\u73af\u5883\u4e2d\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u6e05\u7406\u4e0d\u518d\u9700\u8981\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<p><p><strong>1\u3001\u5378\u8f7d\u5e93\u5931\u8d25<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528pip\u5de5\u5177\u5378\u8f7d\u5e93\u53ef\u80fd\u4f1a\u5931\u8d25\uff0c\u63d0\u793a\u6743\u9650\u4e0d\u8db3\u6216\u6587\u4ef6\u6b63\u5728\u4f7f\u7528\u7b49\u9519\u8bef\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/li>\n<li>\u786e\u4fdd\u6ca1\u6709\u5176\u4ed6\u7a0b\u5e8f\u6b63\u5728\u4f7f\u7528\u8be5\u5e93\u3002<\/li>\n<li>\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p><p><strong>2\u3001\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5378\u8f7d\u67d0\u4e2a\u5e93\u540e\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5176\u4ed6\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u6765\u68c0\u67e5\u5e76\u4fee\u590d\u4f9d\u8d56\u5173\u7cfb\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u4f9d\u8d56\u5173\u7cfb\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip check<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u53d1\u73b0\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5\u76f8\u5173\u5e93\u6216\u66f4\u65b0\u4f9d\u8d56\u5173\u7cfb\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --upgrade -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>3\u3001\u73af\u5883\u9694\u79bb<\/strong><\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u5378\u8f7d\u5e93\u65f6\u5bf9\u5176\u4ed6\u9879\u76ee\u4ea7\u751f\u5f71\u54cd\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6216Anaconda\u73af\u5883\u6765\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u6bcf\u4e2a\u9879\u76ee\u90fd\u6709\u72ec\u7acb\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4e0d\u4f1a\u76f8\u4e92\u5e72\u6270\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528pip\u5de5\u5177\u3001\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\u3001\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u7b49\u3002<strong>\u4f7f\u7528pip\u5de5\u5177<\/strong>\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u65b9\u4fbf\u5feb\u6377\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u60c5\u51b5\u3002\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6\u9002\u7528\u4e8e\u624b\u52a8\u5b89\u88c5\u7684\u5e93\u6216\u65e0\u6cd5\u901a\u8fc7pip\u5de5\u5177\u5378\u8f7d\u7684\u5e93\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u5730\u7ba1\u7406\u548c\u5378\u8f7d\u5e93\uff0c\u907f\u514d\u4f9d\u8d56\u5173\u7cfb\u51b2\u7a81\u3002\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5378\u8f7d\u9002\u7528\u4e8e\u901a\u8fc7\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u7684\u5e93\u3002\u5728\u5378\u8f7d\u5e93\u65f6\uff0c\u5efa\u8bae\u5907\u4efd\u548c\u8bb0\u5f55\u5f53\u524d\u73af\u5883\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u51b2\u7a81\uff0c\u5b9a\u671f\u6e05\u7406\u4e0d\u518d\u4f7f\u7528\u7684\u5e93\u3002\u540c\u65f6\uff0c\u8981\u6ce8\u610f\u5904\u7406\u5378\u8f7d\u5e93\u5931\u8d25\u548c\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898\uff0c\u786e\u4fdd\u73af\u5883\u7684\u7a33\u5b9a\u548c\u9ad8\u6548\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u5e93\u5217\u8868\uff1f<\/strong><br \/>\u5728\u5378\u8f7dPython\u5e93\u4e4b\u524d\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u67e5\u770b\u5f53\u524d\u5df2\u5b89\u88c5\u7684\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 <code>pip list<\/code> \u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u67e5\u770b\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002\u6b64\u5916\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7 <code>pip freeze<\/code> \u83b7\u53d6\u66f4\u8be6\u7ec6\u7684\u8f93\u51fa\uff0c\u9002\u5408\u7528\u4e8e\u751f\u6210\u9700\u6c42\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5378\u8f7dPython\u5e93\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u5378\u8f7dPython\u5e93\u65f6\uff0c\u786e\u4fdd\u9996\u5148\u4e86\u89e3\u8be5\u5e93\u662f\u5426\u662f\u5176\u4ed6\u9879\u76ee\u6240\u4f9d\u8d56\u7684\u3002\u5378\u8f7d\u4e00\u4e2a\u5e93\u53ef\u80fd\u4f1a\u5f71\u54cd\u5230\u4f9d\u8d56\u5b83\u7684\u5176\u4ed6\u5e93\u6216\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528 <code>pip show [\u5e93\u540d]<\/code> \u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u8be5\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u5e2e\u52a9\u60a8\u505a\u51fa\u66f4\u660e\u667a\u7684\u51b3\u5b9a\u3002<\/p>\n<p><strong>\u4f7f\u7528pip\u4ee5\u5916\u7684\u5de5\u5177\u5378\u8f7dPython\u5e93\u662f\u5426\u53ef\u884c\uff1f<\/strong><br \/>\u9664\u4e86\u4f7f\u7528pip\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Anaconda\u7b49\u5176\u4ed6\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5378\u8f7dPython\u5e93\u3002\u5728Anaconda\u73af\u5883\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 <code>conda remove [\u5e93\u540d]<\/code> \u6765\u5b8c\u6210\u5378\u8f7d\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u5728\u76f8\u5e94\u7684\u73af\u5883\u4e2d\u6267\u884c\u5378\u8f7d\u547d\u4ee4\uff0c\u4ee5\u514d\u5f71\u54cd\u5168\u5c40\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u5378\u8f7dPython\u5b89\u88c5\u7684\u5e93\uff1a\u53ef\u4ee5\u901a\u8fc7pip\u5de5\u5177\u3001\u76f4\u63a5\u5220\u9664\u5e93\u6587\u4ef6\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\u3001\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u7b49\u65b9\u6cd5\u6765\u5378 [&hellip;]","protected":false},"author":3,"featured_media":1170621,"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\/1170609"}],"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=1170609"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170609\/revisions"}],"predecessor-version":[{"id":1170623,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170609\/revisions\/1170623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1170621"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1170609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1170609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1170609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}