{"id":331,"date":"2026-07-08T16:39:17","date_gmt":"2026-07-08T08:39:17","guid":{"rendered":"https:\/\/numsimlab.com\/?p=331"},"modified":"2026-07-08T16:39:17","modified_gmt":"2026-07-08T08:39:17","slug":"uv%e5%b7%a5%e5%85%b7%e9%9b%b6%e5%9f%ba%e7%a1%80%e5%ae%8c%e6%95%b4%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/numsimlab.com\/?p=331","title":{"rendered":"uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u6559\u7a0b"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u6559\u7a0b<\/title>\n<style>\n*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}\nhtml{scroll-behavior:smooth}\n:root{\n  --bg:#f8f9fa;--bg2:#fff;--ink:#1a1a2e;--muted:#6c7086;--rule:#e2e4eb;\n  --accent:#2563eb;--accent2:#16a34a;--accent3:#dc2626;--accent4:#d97706;--accent5:#7c3aed;\n  --card-bg:#fff;--code-bg:#f1f3f5;\n  --tag-g:#dcfce7;--tag-g-t:#166534;--tag-b:#dbeafe;--tag-b-t:#1e40af;\n  --tag-r:#fee2e2;--tag-r-t:#991b1b;--tag-y:#fef9c3;--tag-y-t:#713f12;--tag-p:#f3e8ff;--tag-p-t:#581c87;\n  --shadow:0 1px 3px rgba(0,0,.08);--radius:8px;--max-w:940px\n}\n[data-theme=\"dark\"]{\n  --bg:#0b0b1a;--bg2:#16162a;--ink:#e2e4f0;--muted:#7f8396;--rule:#26263e;\n  --accent:#60a5fa;--accent2:#4ade80;--accent3:#f87171;--accent4:#fbbf24;--accent5:#a78bfa;\n  --card-bg:#16162a;--code-bg:#1e36;\n  --tag-g:#14532d;--tag-g-t:#bbf7d0;--tag-b:#1e3a5f;--tag-b-t:#bfdbfe;\n  --tag-r:#7f1d1d;--tag-r-t:#fecaca;--tag-y:#713f12;--tag-y-t:#fef08a;\n  --tag-p:#3b1f6e;--tag-p-t:#e9d5ff;\n  --shadow:0 1px 3px rgba(0,0,.3)\n}\nbody{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",\"Noto Sans SC\",\"PingFang SC\",\"Microsoft YaHei\",sans-serif;background:var(--bg);color:var(--ink);line-height:1.7;font-size:15px;transition:background .3s,color .3s}\nheader{position:fixed;top:0;left:0;right:0;z-index:100;background:var(--bg2);border-bottom:1px solid var(--rule);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);transition:background .3s}\n.header-inner{max-width:var(--max-w);margin:0 auto;display:flex;align-items:center;justify-content:space-between;padding:0 1.5rem;height:56px}\n.logo{font-weight:700;font-size:.95rem;color:var(--accent);display:flex;align-items:center;gap:.4rem}\n.controls{display:flex;align-items:center;gap:.5rem}\n.lang-switch{display:flex;border:1px solid var(--rule);border-radius:6px;overflow:hidden}\n.lang-switch button{background:0 0;border:none;color:var(--muted);padding:.3rem .7rem;font-size:.8rem;cursor:pointer;transition:all .2s;font-family:inherit}\n.lang-switch button.active{background:var(--accent);color:#fff}\n.lang-switch button:not(.active):hover{color:var(--ink);background:var(--rule)}\n.theme-toggle{background:0 0;border:1px solid var(--rule);border-radius:6px;color:var(--muted);width:34px;height:34px;font-size:1rem;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s}\n.theme-toggle:hover{color:var(--ink);background:var(--rule)}\nmain{max-width:var(--max-w);margin:0 auto;padding:80px 1.5rem 3rem}\n.lang-section{display:none}.lang-section.active{display:block}\nh1{font-size:1.9rem;font-weight:800;line-height:1.3;margin-bottom:.5rem;letter-spacing:-.02em}\nh1 .sub{display:block;font-size:.85rem;font-weight:400;color:var(--muted);margin-top:.25rem;letter-spacing:0}\nh2{font-size:1.35rem;font-weight:700;margin:2.5rem 0 1rem;padding-bottom:.5rem;border-bottom:2px solid var(--accent);letter-spacing:-.01em}\nh3{font-size:1.05rem;font-weight:600;margin:1.5rem 0 .6rem;color:var(--accent)}\nh4{font-size:.95rem;font-weight:600;margin:1rem 0 .4rem;color:var(--ink)}\np{margin-bottom:.8rem}\na{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}\n.hero{text-align:center;padding:2rem 0 1rem}\n.hero p{font-size:1rem;color:var(--muted);max-width:700px;margin:0 auto}\n.tag{display:inline-block;padding:.12rem .5rem;border-radius:4px;font-size:.72rem;font-weight:600;margin-right:.25rem;white-space:nowrap}\n.tag-g{background:var(--tag-g);color:var(--tag-g-t)}.tag-b{background:var(--tag-b);color:var(--tag-b-t)}\n.tag-r{background:var(--tag-r);color:var(--tag-r-t)}.tag-y{background:var(--tag-y);color:var(--tag-y-t)}.tag-p{background:var(--tag-p);color:var(--tag-p-t)}\n.card{background:var(--card-bg);border:1px solid var(--rule);border-radius:var(--radius);padding:1.25rem;margin-bottom:1rem;box-shadow:var(--shadow)}\n.info-box{background:var(--bg);border-left:4px solid var(--accent);padding:.9rem 1.1rem;margin:1rem 0;border-radius:0 var(--radius) var(--radius) 0;font-size:.88rem}\n.info-box strong{color:var(--accent)}\n.info-box.warn{border-left-color:var(--accent4)}.info-box.danger{border-left-color:var(--accent3)}\n.toc{background:var(--card-bg);border:1px solid var(--rule);border-radius:var(--radius);padding:1.15rem 1.4rem;margin-bottom:2rem;box-shadow:var(--shadow)}\n.toc h3{margin:0 0 .5rem;font-size:.9rem;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}\n.toc ol{padding-left:1.1rem;columns:2;column-gap:2rem}\n.toc li{margin-bottom:.25rem;font-size:.88rem}.toc a{color:var(--ink)}.toc a:hover{color:var(--accent);text-decoration:none}\npre.code-block{background:var(--code-bg);padding:.85rem 1rem;border-radius:var(--radius);overflow-x:auto;font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.82rem;line-height:1.5;margin:.6rem 0;border:1px solid var(--rule)}\ncode,.inline-code{background:var(--code-bg);padding:.12rem .4rem;border-radius:4px;font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.83rem;border:1px solid var(--rule)}\n.table-wrap{overflow-x:auto;margin:1.2rem 0}\ntable{width:100%;border-collapse:collapse;font-size:.82rem}\nthead th{background:var(--accent);color:#fff;padding:.6rem .5rem;text-align:center;font-weight:600;white-space:nowrap}\nthead th:first-child{border-radius:6px 0 0 0}thead th:last-child{border-radius:0 6px 0 0}\ntbody td{padding:.55rem .5rem;border-bottom:1px solid var(--rule);text-align:center;vertical-align:middle}\ntbody tr:nth-child(even){background:var(--bg)}\ntbody td:first-child{text-align:left;font-weight:600}\n.terminal{background:#1a1a2e;color:#a8e6cf;border-radius:var(--radius);padding:.9rem 1rem;font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.82rem;line-height:1.6;margin:.6rem 0;overflow-x:auto;border:1px solid #333}\n.terminal .prompt{color:#60a5fa}.terminal .comment{color:#6c7086;font-style:italic}.terminal .output{color:#e2e4f0}\n[data-theme=\"dark\"] .terminal{background:#08081a}\n.steps{counter-reset:step;list-style:none;padding:0}\n.steps li{counter-increment:step;position:relative;padding:.85rem 1rem .85rem 2.8rem;margin-bottom:.5rem;border-left:2px solid var(--rule);border-radius:0 var(--radius) 0;background:var(--card-bg);box-shadow:var(--shadow)}\n.steps li::before{content:counter(step);position:absolute;left:-13px;top:.85rem;width:26px;height:26px;border-radius:50%;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:.78rem;font-weight:700}\n.steps li .cmd{display:block;background:var(--code-bg);padding:.4rem .7rem;border-radius:5px;font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.82rem;margin:.3rem 0;overflow-x:auto;border:1px solid var(--rule)}\n.steps li .note{display:block;color:var(--muted);font-size:.82rem;margin-top:.2rem}\n.flow-diagram{background:var(--card-bg);border:1px solid var(--rule);border-radius:var(--radius);padding:1.25rem;margin:1.25rem 0;text-align:center}\n.flow-row{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:.35rem;margin:.4rem 0}\n.flow-item{display:inline-block;padding:.4rem .8rem;border-radius:6px;font-weight:600;font-size:.82rem;text-align:center;background:var(--accent);color:#fff;min-width:60px}\n.flow-item.green{background:var(--accent2)}.flow-item.red{background:var(--accent3)}.flow-item.yellow{background:var(--accent4);color:#1a1a2e}.flow-item.purple{background:var(--accent5)}\n.flow-arrow{color:var(--muted);font-size:1rem}\n.cmd-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:.75rem;margin:1rem 0}\n.cmd-card{background:var(--card-bg);border:1px solid var(--rule);border-radius:var(--radius);padding:.9rem;box-shadow:var(--shadow)}\n.cmd-card h4{margin:0 0 .35rem;font-size:.88rem;color:var(--accent)}\n.cmd-card .cmd{font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.8rem;background:var(--code-bg);padding:.3rem .5rem;border-radius:4px;display:block;margin-bottom:.3rem}\n.cmd-card .desc{font-size:.8rem;color:var(--muted)}\n.two-col{display:grid;grid-template-columns:1fr 1fr;gap:1.25rem;margin:1.25rem 0}\n.compare-box{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:1rem 0}\n.compare-col{background:var(--card-bg);border:1px solid var(--rule);border-radius:var(--radius);padding:1rem;box-shadow:var(--shadow)}\n.compare-col h4{margin:0 0 .4rem;font-size:.88rem}\n.compare-col.bad h4{color:var(--accent3)}.compare-col.good h4{color:var(--accent2)}\npre.example{background:var(--code-bg);padding:.6rem .8rem;border-radius:6px;font-family:\"SF Mono\",Consolas,\"Courier New\",monospace;font-size:.78rem;line-height:1.5;margin:.4rem 0;border:1px solid var(--rule);color:var(--ink)}\nfooter{max-width:940px;margin:3rem auto 0;padding:2rem 1.5rem 3rem;border-top:1px solid var(--rule);text-align:center;font-size:.82rem;color:var(--muted)}\nfooter .links{display:flex;justify-content:center;gap:1.5rem;flex-wrap:wrap;margin-bottom:.8rem}\nfooter .links a{color:var(--muted)}footer .links a:hover{color:var(--accent)}\n@media(max-width:640px){\n  h1{font-size:1.4rem}.toc ol{columns:1}.header-inner{padding:0 1rem}main{padding:72px 1rem 2rem}\n  .steps li{padding-left:2.4rem}.steps li::before{left:-11px;width:22px;height:font-size:.7rem}\n  .two-col{grid-template-columns:1fr}.cmd-grid{grid-template-columns:1fr}.compare-box{grid-template-columns:1fr}\n}\n<\/style>\n<\/head>\n<body>\n<header>\n  <div class=\"header-inner\">\n    <div class=\"logo\"><span>\u26a1<\/span> uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u6559\u7a0b<\/div>\n    <div class=\"controls\">\n      <div class=\"lang-switch\">\n        <button class=\"active\" onclick=\"setLang('zh')\" id=\"btn-zh\">\u4e2d\u6587<\/button>\n        <button onclick=\"setLang('en')\" id=\"btn-en\">English<\/button>\n      <\/div>\n      <button class=\"theme-toggle\" onclick=\"toggleTheme()\" title=\"\u5207\u6362\u660e\u6697\u4e3b\u9898\">&#9788;<\/button>\n    <\/div>\n  <\/div>\n<\/header>\n<main>\n<div class=\"lang-section active\" id=\"lang-zh\">\n<div class=\"hero\">\n  <h1>uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u8bb2\u89e3\uff1a\u662f\u4ec0\u4e48\u3001\u6709\u4ec0\u4e48\u7528\u3001\u5168\u5957\u5b9e\u64cd\u547d\u4ee4<\/h1>\n  <p class=\"sub\">\u9002\u914d\u6240\u6709Python\u9879\u76ee\uff0c\u548cRuff\u540c\u6e90\u4e00\u4f53\u5316\u5de5\u5177\uff0c\u96f6\u57fa\u7840\u4ece\u5b89\u88c5\u5230\u9879\u76ee\u5b8c\u6574\u6d41\u7a0b\u4e00\u6b65\u4e00\u6b65\u6f14\u793a<\/p>\n<\/div>\n<div class=\"toc\">\n  <h3>\u76ee\u5f55<\/h3>\n  <ol>\n    <li><a href=\"#s1\">\u4e00\u3001uv\u662f\u4ec0\u4e48\uff1f\u5f00\u53d1\u5382\u5546\u4e0e\u6838\u5fc3\u5b9a\u4f4d<\/a><\/li>\n    <li><a href=\"#s2\">\u4e8c\u3001\u539f\u751fpip\/venv\u75db\u70b9 vs uv\u6838\u5fc3\u4f18\u52bf<\/a><\/li>\n    <li><a href=\"#s3\">\u4e09\u3001\u8de8\u5e73\u53f0\u4e00\u952e\u5b89\u88c5uv<\/a><\/li>\n    <li><a href=\"#s4\">\u56db\u3001\u9501\u5b9a\u9879\u76eePython\u7248\u672c uv python pin<\/a><\/li>\n    <li><a href=\"#s5\">\u4e94\u3001\u521b\u5efa\u9694\u79bb\u865a\u62df\u73af\u5883 uv venv<\/a><\/li>\n    <li><a href=\"#s6\">\u516d\u3001\u5b89\u88c5\/\u5378\u8f7d\u9879\u76ee\u4f9d\u8d56 uv add \/ remove<\/a><\/li>\n    <li><a href=\"#s7\">\u4e03\u3001\u533a\u5206\u8fd0\u884c\u4f9d\u8d56\u4e0e\u5f00\u53d1\u4f9d\u8d56 &#8211;dev<\/a><\/li>\n    <li><a href=\"#s8\">\u516b\u3001\u65e0\u9700\u624b\u52a8\u6fc0\u6d3b\uff1auv run \u8fd0\u884c\u4ee3\u7801\/\u5de5\u5177<\/a><\/li>\n    <li><a href=\"#s9\">\u4e5d\u3001\u591a\u4eba\u534f\u4f5c\u7edf\u4e00\u73af\u5883 uv sync<\/a><\/li>\n    <li><a href=\"#s10\">\u5341\u3001\u9ad8\u9891\u8f85\u52a9\u67e5\u8be2\u547d\u4ee4\u5927\u5168<\/a><\/li>\n    <li><a href=\"#s11\">\u5341\u4e00\u3001\u5b8c\u6574\u65b0\u9879\u76ee\u6807\u51c6\u64cd\u4f5c\u6d41\u7a0b<\/a><\/li>\n  <\/ol>\n<\/div>\n\n<h2 id=\"s1\">\u4e00\u3001uv\u662f\u4ec0\u4e48\uff1f\u5f00\u53d1\u5382\u5546\u4e0e\u6838\u5fc3\u5b9a\u4f4d<\/h2>\n<div class=\"card\">\n  <h4>\u96f6\u57fa\u7840\u5927\u767d\u8bdd\u89e3\u91ca<\/h4>\n  <p>uv\u662fAstral\u516c\u53f8\u4f7f\u7528Rust\u8bed\u8a00\u5f00\u53d1\u7684Python\u4e00\u4f53\u5316\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u548c\u4ee3\u7801\u89c4\u8303\u5de5\u5177Ruff\u51fa\u81ea\u540c\u4e00\u56e2\u961f\uff0c\u662f2026\u5e74\u73b0\u4ee3Python\u9879\u76ee\u5de5\u4e1a\u6807\u51c6\u5de5\u5177\u3002<\/p>\n  <p>\u8fc7\u53bb\u5199Python\u7a0b\u5e8f\uff0c\u9700\u8981\u5206\u5f00\u4f7f\u7528pip\u88c5\u5305\u3001venv\u521b\u5efa\u865a\u62df\u73af\u5883\u3001\u624b\u52a8\u7ef4\u62a4requirements.txt\u3001\u624b\u52a8\u6fc0\u6d3b\u73af\u5883\u8fd0\u884c\u811a\u672c\uff0c\u547d\u4ee4\u96f6\u6563\u3001\u5bb9\u6613\u51fa\u73b0\u7248\u672c\u51b2\u7a81\u3001\u4e0b\u8f7d\u7f13\u6162\u3002<\/p>\n  <p>uv\u628a<strong>Python\u7248\u672c\u9501\u5b9a\u3001\u865a\u62df\u73af\u5883\u3001\u4f9d\u8d56\u5b89\u88c5\u5378\u8f7d\u3001\u9879\u76ee\u914d\u7f6e\u7ba1\u7406\u3001\u811a\u672c\u8fd0\u884c<\/strong>\u5168\u90e8\u6574\u5408\u4e3a\u4e00\u5957\u7edf\u4e00\u547d\u4ee4\uff0c\u901f\u5ea6\u6bd4\u539f\u751fpip\u5feb\u6570\u5341\u81f3\u767e\u500d\uff0c\u5168\u7a0b\u8de8Windows\/Mac\/Linux\u547d\u4ee4\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n<\/div>\n<div class=\"info-box\">\n  <strong>\u9002\u7528\u573a\u666f\uff1a<\/strong>AI\u4ee3\u7801\u52a9\u624b\u3001\u540e\u7aef\u670d\u52a1\u3001\u6253\u5305\u684c\u9762exe\u3001\u5f00\u6e90\u9879\u76ee\u7edf\u4e00\u73af\u5883\u7ba1\u7406\u3002\n<\/div>\n\n<h2 id=\"s2\">\u4e8c\u3001\u539f\u751fpip\/venv\u75db\u70b9 vs uv\u6838\u5fc3\u4f18\u52bf<\/h2>\n<div class=\"two-col\">\n  <div class=\"compare-col bad\">\n    <h4>\u539f\u751fpip+venv \u4f20\u7edf\u75db\u70b9<\/h4>\n    <ul>\n      <li>\u4f9d\u8d56\u4e0b\u8f7d\u3001\u89e3\u6790\u901f\u5ea6\u6781\u6162\uff0c\u5927\u578b\u9879\u76ee\u7b49\u5f85\u5f88\u4e45<\/li>\n      <li>\u865a\u62df\u73af\u5883\u521b\u5efa\u3001\u6fc0\u6d3b\u547d\u4ee4\u590d\u6742\uff0c\u65b0\u624b\u6781\u6613\u9057\u5fd8<\/li>\n      <li>\u65e0\u6cd5\u533a\u5206\u5f00\u53d1\u5de5\u5177\u548c\u7ebf\u4e0a\u8fd0\u884c\u4f9d\u8d56\uff0c\u6253\u5305\u5197\u4f59<\/li>\n      <li>\u591a\u8bbe\u5907\u534f\u4f5c\u65f6\u4f9d\u8d56\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u672c\u5730\u80fd\u8dd1\u522b\u4eba\u62a5\u9519<\/li>\n      <li>\u9700\u8981\u624b\u52a8\u7ef4\u62a4\u4f9d\u8d56\u6e05\u5355\u6587\u4ef6\uff0c\u5bb9\u6613\u6f0f\u5199\u5305<\/li>\n      <li>\u6bcf\u6b21\u8fd0\u884c\u4ee3\u7801\u524d\u5fc5\u987b\u624b\u52a8\u6fc0\u6d3bvenv\uff0c\u5fd8\u8bb0\u5c31\u5168\u5c40\u5305\u51b2\u7a81<\/li>\n    <\/ul>\n  <\/div>\n  <div class=\"compare-col good\">\n    <h4>uv \u6838\u5fc3\u4f18\u52bf<\/h4>\n    <ul>\n      <li>Rust\u5e95\u5c42\u9ad8\u6027\u80fd\uff0c\u4f9d\u8d56\u5b89\u88c5\u63d0\u901f50~100\u500d<\/li>\n      <li>uv run\u81ea\u52a8\u52a0\u8f7d\u865a\u62df\u73af\u5883\uff0c\u5168\u7a0b\u65e0\u9700\u624b\u52a8activate<\/li>\n      <li>\u539f\u751f&#8211;dev\u53c2\u6570\u9694\u79bb\u5f00\u53d1\u4f9d\u8d56\uff0c\u6253\u5305\u81ea\u52a8\u5254\u9664\u5de5\u5177\u5305<\/li>\n      <li>\u81ea\u52a8\u8bfb\u5199pyproject.toml\uff0c\u5168\u5c40\u9501\u5b9a\u6240\u6709\u4f9d\u8d56\u7248\u672c<\/li>\n      <li>Windows\/Mac\/Linux\u547d\u4ee4\u5b8c\u5168\u7edf\u4e00\uff0c\u8de8\u7cfb\u7edf\u65e0\u5dee\u5f02<\/li>\n      <li>\u548cRuff\u540c\u751f\u6001\uff0c\u4e00\u5957\u5de5\u5177\u540c\u65f6\u7ba1\u7406\u4f9d\u8d56+\u4ee3\u7801\u89c4\u8303<\/li>\n    <\/ul>\n  <\/div>\n<\/div>\n\n<h2 id=\"s3\">\u4e09\u3001\u8de8\u5e73\u53f0\u4e00\u952e\u5b89\u88c5uv<\/h2>\n<div class=\"cmd-grid\">\n  <div class=\"cmd-card\">\n    <h4>Windows\uff08\u7ba1\u7406\u5458PowerShell\uff09<\/h4>\n    <div class=\"cmd\">irm https:\/\/astral.sh\/uv\/install.ps1 | iex<\/div>\n    <div class=\"desc\">\u590d\u5236\u6574\u884c\u7c98\u8d34\u6267\u884c\uff0c\u5b8c\u6210\u540e\u91cd\u542f\u7ec8\u7aef\u751f\u6548<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>Mac \/ Linux \u7ec8\u7aef<\/h4>\n    <div class=\"cmd\">curl -LsSf https:\/\/astral.sh\/uv\/install.sh | sh<\/div>\n    <div class=\"desc\">\u6267\u884c\u5b8c\u6bd5\u5173\u95ed\u7ec8\u7aef\u91cd\u65b0\u6253\u5f00\u624d\u80fd\u8bc6\u522buv\u547d\u4ee4<\/div>\n  <\/div>\n<\/div>\n<div class=\"info-box\">\n  <strong>\u5b89\u88c5\u9a8c\u8bc1\uff1a<\/strong>\u65b0\u5f00\u7ec8\u7aef\u8f93\u5165 <code>uv --version<\/code>\uff0c\u8f93\u51fa\u7248\u672c\u53f7\u4ee3\u8868\u5b89\u88c5\u6210\u529f\u3002\n<\/div>\n\n<h2 id=\"s4\">\u56db\u3001\u9501\u5b9a\u9879\u76eePython\u7248\u672c uv python pin<\/h2>\n<div class=\"card\">\n  <h4>\u96f6\u57fa\u7840\u4f5c\u7528\u8bb2\u89e3<\/h4>\n  <p>\u4e0d\u540c\u7535\u8111\u9884\u88c5Python3.9\/3.10\/3.12\u7248\u672c\u6df7\u6742\uff0c\u8bed\u6cd5\u3001\u7b2c\u4e09\u65b9\u5e93\u517c\u5bb9\u5b58\u5728\u5dee\u5f02\u3002uv python pin 3.12\u4f1a\u81ea\u52a8\u751f\u6210.python-version\u6587\u4ef6\uff0c\u5f3a\u5236\u672c\u9879\u76ee\u7edf\u4e00Python\u7248\u672c\uff0c\u56e2\u961f\u6240\u6709\u4eba\u6253\u5f00\u9879\u76ee\u81ea\u52a8\u5339\u914d\uff0c\u6d88\u9664\u7248\u672c\u4e0d\u517c\u5bb9\u62a5\u9519\u3002<\/p>\n<\/div>\n<pre class=\"code-block\">uv python pin 3.12\n<\/pre>\n\n<h2 id=\"s5\">\u4e94\u3001\u521b\u5efa\u9694\u79bb\u865a\u62df\u73af\u5883 uv venv<\/h2>\n<div class=\"card\">\n  <h4>\u96f6\u57fa\u7840\u8bb2\u89e3\u865a\u62df\u73af\u5883<\/h4>\n  <p>\u7535\u8111\u5168\u5c40Python\u4f1a\u5b89\u88c5\u5927\u91cf\u5de5\u5177\u5305\uff0c\u9879\u76ee\u4e4b\u95f4\u5305\u7248\u672c\u8981\u6c42\u51b2\u7a81\u3002\u865a\u62df\u73af\u5883.venv\u662f\u5f53\u524d\u9879\u76ee\u72ec\u7acb\u8f6f\u4ef6\u4ed3\u5e93\uff0c\u672c\u9879\u76ee\u6240\u6709\u4f9d\u8d56\u4ec5\u5b58\u653e\u5728\u8fd9\u91cc\uff0c\u4e0d\u4f1a\u6c61\u67d3\u5168\u5c40Python\uff0c\u5207\u6362\u9879\u76ee\u65e0\u5305\u51b2\u7a81\u3002<\/p>\n<\/div>\n<pre class=\"code-block\">uv venv\n<\/pre>\n<div class=\"info-box warn\">\n  <strong>Git\u89c4\u8303\uff1a<\/strong>.venv\u6587\u4ef6\u5939\u4f53\u79ef\u8f83\u5927\uff0c\u5fc5\u987b\u5199\u5165.gitignore\u5c4f\u853d\uff0c\u7981\u6b62\u4e0a\u4f20\u4ee3\u7801\u4ed3\u5e93\u3002\n<\/div>\n\n<h2 id=\"s6\">\u516d\u3001\u5b89\u88c5\/\u5378\u8f7d\u9879\u76ee\u4f9d\u8d56 uv add \/ remove<\/h2>\n<h3>1. \u5b89\u88c5\u7a0b\u5e8f\u8fd0\u884c\u5fc5\u9700\u4f9d\u8d56<\/h3>\n<pre class=\"code-block\"># \u57fa\u7840\u683c\u5f0f uv add \u5305\u540d\nuv add openai python-dotenv pydantic\n# \u6307\u5b9a\u6700\u4f4e\u517c\u5bb9\u7248\u672c\nuv add openai>=1.30.0\n<\/pre>\n<h3>2. \u5378\u8f7d\u65e0\u7528\u4f9d\u8d56\u5305<\/h3>\n<pre class=\"code-block\">uv remove pydantic\n<\/pre>\n<h3>3. \u5347\u7ea7\u6240\u6709\u517c\u5bb9\u4f9d\u8d56\u5230\u6700\u65b0\u7a33\u5b9a\u7248<\/h3>\n<pre class=\"code-block\">uv sync --upgrade\n<\/pre>\n\n<h2 id=\"s7\">\u4e03\u3001\u533a\u5206\u8fd0\u884c\u4f9d\u8d56\u4e0e\u5f00\u53d1\u4f9d\u8d56 &#8211;dev<\/h2>\n<div class=\"card\">\n  <h4>\u96f6\u57fa\u7840\u533a\u5206\u6982\u5ff5<\/h4>\n  <p><span class=\"tag-b\">\u8fd0\u884c\u4f9d\u8d56\uff08\u65e0&#8211;dev\uff09\uff1a<\/span>\u7a0b\u5e8f\u6253\u5305\u3001\u53d1\u7ed9\u666e\u901a\u7528\u6237\u8fd0\u884c\u5fc5\u987b\u7684\u6838\u5fc3\u5305\uff0c\u5982AI\u63a5\u53e3SDK\u3001\u8bfb\u53d6.env\u5de5\u5177\uff1b<\/p>\n  <p><span class=\"tag-y\">\u5f00\u53d1\u4f9d\u8d56\uff08&#8211;dev\uff09\uff1a<\/span>\u4ec5\u7f16\u7801\u3001\u8c03\u8bd5\u3001\u6253\u5305\u9636\u6bb5\u4f7f\u7528\uff0c\u53d1\u7ed9\u7528\u6237\u7684exe\u4e0d\u9700\u8981\uff0c\u6253\u5305\u65f6\u81ea\u52a8\u5254\u9664\uff0c\u51cf\u5c0f\u7a0b\u5e8f\u4f53\u79ef\u3002\u4ee3\u8868\u5de5\u5177\uff1aruff\u3001pyinstaller\u3001pytest\u5355\u5143\u6d4b\u8bd5\u3002<\/p>\n<\/div>\n<pre class=\"code-block\"># \u5f00\u53d1\u4e13\u7528\u5de5\u5177\u5b89\u88c5\nuv add --dev ruff pyinstaller pytest\n<\/pre>\n\n<h2 id=\"s8\">\u516b\u3001\u65e0\u9700\u624b\u52a8\u6fc0\u6d3b\uff1auv run \u8fd0\u884c\u4ee3\u7801\/\u5de5\u5177<\/h2>\n<div class=\"card\">\n  <h4>\u6838\u5fc3\u4fbf\u5229\u70b9\u8bf4\u660e<\/h4>\n  <p>\u4f20\u7edfvenv\u9700\u8981\u624b\u52a8\u6267\u884c\u6fc0\u6d3b\u811a\u672c\uff0c\u65b0\u624b\u6781\u6613\u5fd8\u8bb0\uff0c\u5bfc\u81f4\u7a0b\u5e8f\u8c03\u7528\u5168\u5c40\u5305\u51fa\u73b0\u7248\u672c\u62a5\u9519\u3002uv run\u4f1a\u81ea\u52a8\u8bfb\u53d6\u5f53\u524d\u76ee\u5f55.venv\u865a\u62df\u73af\u5883\uff0c\u4e0d\u7528\u5207\u6362\u6fc0\u6d3b\u547d\u4ee4\uff0c\u76f4\u63a5\u8fd0\u884cPython\u811a\u672c\u6216Ruff\u7b49\u5de5\u5177\u3002<\/p>\n<\/div>\n<div class=\"cmd-grid\">\n  <div class=\"cmd-card\">\n    <h4>\u8fd0\u884c\u9879\u76ee\u5165\u53e3\u7a0b\u5e8f<\/h4>\n    <div class=\"cmd\">uv run python main.py<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>\u8fd0\u884cRuff\u4ee3\u7801\u89c4\u8303\u4fee\u590d<\/h4>\n    <div class=\"cmd\">uv run ruff check . &#8211;fix<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>\u6267\u884c\u5355\u5143\u6d4b\u8bd5<\/h4>\n    <div class=\"cmd\">uv run pytest tests\/<\/div>\n  <\/div>\n<\/div>\n\n<h2 id=\"s9\">\u4e5d\u3001\u591a\u4eba\u534f\u4f5c\u7edf\u4e00\u73af\u5883 uv sync<\/h2>\n<div class=\"card\">\n  <h4>\u4f5c\u7528\u8bb2\u89e3<\/h4>\n  <p>\u56e2\u961f\u5176\u4ed6\u6210\u5458\u3001\u6362\u7535\u8111\u5f00\u53d1\u65f6\uff0c\u4ec5\u62c9\u53d6\u4ee3\u7801\u65e0\u672c\u5730\u4f9d\u8d56\u3002\u6267\u884cuv sync\u81ea\u52a8\u8bfb\u53d6pyproject.toml\u8bb0\u5f55\u7684\u5168\u90e8\u4f9d\u8d56\uff0c\u7cbe\u51c6\u5b89\u88c5\u5bf9\u5e94\u7248\u672c\uff0c\u4fdd\u8bc1\u6240\u6709\u4eba\u8fd0\u884c\u73af\u5883\u5b8c\u5168\u4e00\u81f4\uff0c\u5f7b\u5e95\u89e3\u51b3\u201c\u6211\u672c\u5730\u80fd\u8dd1\u4f60\u7535\u8111\u62a5\u9519\u201d\u95ee\u9898\u3002<\/p>\n<\/div>\n<pre class=\"terminal\">uv sync\n<\/pre>\n\n<h2 id=\"s10\">\u5341\u3001\u9ad8\u9891\u8f85\u52a9\u67e5\u8be2\u547d\u4ee4\u5927\u5168<\/h2>\n<div class=\"cmd-grid\">\n  <div class=\"cmd-card\">\n    <h4>\u67e5\u770b\u5f53\u524d\u5df2\u5b89\u88c5\u5168\u90e8\u4f9d\u8d56<\/h4>\n    <div class=\"cmd\">uv list<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>\u68c0\u7d22\u7b2c\u4e09\u65b9\u5e93<\/h4>\n    <div class=\"cmd\">uv search tenacity<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>\u6253\u5370\u4f9d\u8d56\u6811\uff0c\u67e5\u770b\u51b2\u7a81<\/h4>\n    <div class=\"cmd\">uv tree<\/div>\n  <\/div>\n  <div class=\"cmd-card\">\n    <h4>\u6e05\u7406\u672c\u5730\u7f13\u5b58\u5b89\u88c5\u5305<\/h4>\n    <div class=\"cmd\">uv cache clean<\/div>\n  <\/div>\n<\/div>\n\n<h2 id=\"s11\">\u5341\u4e00\u3001\u5b8c\u6574\u65b0\u9879\u76ee\u6807\u51c6\u64cd\u4f5c\u6d41\u7a0b<\/h2>\n<ol class=\"steps\">\n  <li>\u7535\u8111\u7a7a\u767d\u5904\u65b0\u5efa\u9879\u76ee\u6587\u4ef6\u5939\uff0cShift+\u53f3\u952e\u6253\u5f00\u7ec8\u7aef\/PowerShell\uff1b<\/li>\n  <li>\u9501\u5b9a\u7edf\u4e00Python\u7248\u672c\uff1a<div class=\"cmd\">uv python pin 3.12<\/div><\/li>\n  <li>\u521b\u5efa\u9694\u79bb\u865a\u62df\u73af\u5883\uff1a<div class=\"cmd\">uv venv<\/div><\/li>\n  <li>\u5b89\u88c5\u7a0b\u5e8f\u6838\u5fc3\u8fd0\u884c\u4f9d\u8d56\uff1a<div class=\"cmd\">uv add openai python-dotenv<\/div><\/li>\n  <li>\u5b89\u88c5\u5f00\u53d1\u5de5\u5177\u5305\uff1a<div class=\"cmd\">uv add &#8211;dev ruff pyinstaller<\/div><\/li>\n  <li>\u7f16\u5199\u5b8c\u4ee3\u7801\u7edf\u4e00\u89c4\u8303\uff1a<div class=\"cmd\">uv run ruff format . &#038;&#038; uv run ruff check . &#8211;fix<\/div><\/li>\n  <li>\u672c\u5730\u542f\u52a8\u8c03\u8bd5\uff1a<div class=\"cmd\">uv run python main.py<\/div><\/li>\n  <li>\u5176\u4ed6\u5f00\u53d1\u8005\u62ff\u5230\u9879\u76ee\uff0c\u4ec5\u6267\u884c\uff1a<div class=\"cmd\">uv sync<\/div>\u5373\u53ef\u5b8c\u6574\u590d\u73b0\u73af\u5883<\/li>\n<\/ol>\n<div class=\"info-box\">\n  <strong>\u6d41\u7a0b\u603b\u7ed3\uff1a<\/strong>\u4e00\u5957uv\u547d\u4ee4\u8986\u76d6\u9879\u76ee\u4ece\u521d\u59cb\u5316\u3001\u5f00\u53d1\u3001\u56e2\u961f\u534f\u4f5c\u5168\u73af\u5883\u7ba1\u7406\uff0c\u65e0\u590d\u6742\u591a\u5de5\u5177\u5207\u6362\uff0c\u96f6\u57fa\u7840\u5927\u5e45\u964d\u4f4ePython\u73af\u5883\u8e29\u5751\u6982\u7387\u3002\n<\/div>\n<\/div>\n\n<div class=\"lang-section\" id=\"lang-en\">\n<div class=\"hero\">\n  <h1>uv Full Beginner Tutorial: What It Is &#038; Full Command Reference<\/h1>\n  <p class=\"sub\">All-in-one Python environment manager from Astral, paired with Ruff, cross-platform workflow<\/p>\n<\/div>\n<div class=\"toc\">\n  <h3>Table of Contents<\/h3>\n  <ol>\n    <li><a href=\"#e1\">1 Introduction: Creator &#038; Core Purpose<\/a><\/li>\n    <li><a href=\"#e2\">2 Drawbacks of pip\/venv vs uv Advantages<\/a><\/li>\n    <li><a href=\"#e3\">3 Cross-Platform Install Script<\/a><\/li>\n    <li><a href=\"#e4\">4 Pin Python Version uv python pin<\/a><\/li>\n    <li><a href=\"#e5\">5 Create Isolated Virtual Env uv venv<\/a><\/li>\n    <li><a href=\"#e6\">6 Add \/ Remove Dependencies<\/a><\/li>\n    <li><a href=\"#e7\">Dev Dependencies Separation &#8211;dev<\/a><\/li>\n    <li><a href=\"#e8\">Run Scripts Without Activate uv run<\/a><\/li>\n    <li><a href=\"#e9\">Sync Env For Team uv sync<\/a><\/li>\n    <li><a href=\"#e10\">Common Helper Commands<\/a><\/li>\n    <li><a href=\"#e11\">Full New Project Workflow<\/a><\/li>\n  <\/ol>\n<\/div>\n<h2 id=\"e1\">1 Introduction<\/h2>\n<p>uv is a Rust-based Python tool developed by Astral (maker of Ruff). It unifies Python version control, virtual environments, dependency management, and script execution into a single toolchain with far better performance than native pip &#038; venv.<\/p>\n<h2 id=\"e2\">2 Comparison<\/h2>\n<p>Traditional pip\/venv: Slow install, complex activation, cannot split dev deps, inconsistent env across machines.<\/p>\n<p>uv: 50-100x faster, auto env load via uv run, native dev flag, pyproject.toml sync for team collaboration.<\/p>\n<h2 id=\"e3\">Install<\/h2>\n<pre class=\"terminal\"># Windows\nirm https:\/\/astral.sh\/uv\/install.ps1 | iex\n# Mac\/Linux\ncurl -LsSf https:\/\/astral.sh\/uv\/install.sh | sh\n<\/pre>\n<h2 id=\"e4\">Pin Python Version<\/h2>\n<pre class=\"code-block\">uv python pin 3.12<\/pre>\n<h2 id=\"e5\">Create Venv<\/h2>\n<pre class=\"code-block\">uv venv<\/pre>\n<h2 id=\"e6\">Manage Packages<\/h2>\n<pre class=\"code-block\">uv add openai pydantic\nuv remove pydantic\nuv sync --upgrade\n<\/pre>\n<h2 id=\"e7\">Dev Tools<\/h2>\n<pre class=\"code-block\">uv add --dev ruff pyinstaller pytest<\/pre>\n<h2 id=\"e8\">Run Code<\/h2>\n<pre class=\"terminal\">uv run python main.py\nuv run ruff check . --fix\n<\/pre>\n<h2 id=\"e9\">Team Sync<\/h2>\n<pre class=\"terminal\">uv sync<\/pre>\n<h2 id=\"e10\">Helper Commands<\/h2>\n<pre class=\"code-block\">uv list\nuv search xxx\nuv tree\nuv cache clean\n<\/pre>\n<h2 id=\"e11\">Full Project Steps<\/h2>\n<ol class=\"steps\">\n<li>uv python pin 3.12<\/li>\n<li>uv venv<\/li>\n<li>uv add core libs<\/li>\n<li>uv add &#8211;dev tools<\/li>\n<li>uv run lint &#038; format<\/li>\n<li>uv run main.py<\/li>\n<li>Others run uv sync to replicate env<\/li>\n<\/ol>\n<\/div>\n<\/main>\n<script>\nfunction setLang(lang){\n  document.querySelectorAll('.lang-section').forEach(el=>el.classList.remove('active'));\n  document.getElementById('lang-'+lang).classList.add('active');\n  document.querySelectorAll('.lang-switch button').forEach(btn=>btn.classList.remove('active'));\n  document.getElementById('btn-'+lang).classList.add('active');\n  document.documentElement.lang = lang==='zh'?'zh-CN':'en';\n  const prefix = lang==='zh'?'zh':'en';\n  const newHash = window.location.hash.replace(\/^#(zh|en)-\/, prefix+\"-\");\n  if(newHash) window.location.hash = newHash;\n}\nfunction toggleTheme(){\n  const html = document.documentElement;\n  if(html.hasAttribute('data-theme')){\n    html.removeAttribute('data-theme');\n    localStorage.removeItem('theme');\n  }else{\n    html.setAttribute('data-theme','dark');\n    localStorage.setItem('dark');\n  }\n}\n(function(){\n  if(localStorage.getItem('theme')==='dark') document.documentElement.setAttribute('data-theme','dark');\n  const hash = window.location.hash;\n  if(hash){\n    const target = document.querySelector(hash);\n    if(target) setTimeout(()=>target.scrollIntoView({behavior:'smooth'}),100);\n  }\n})();\n<\/script>\n<\/body>\n<\/html>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u6559\u7a0b \u26a1 uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u6559\u7a0b \u4e2d\u6587 English &#9788; uv\u5de5\u5177\u96f6\u57fa\u7840\u5b8c\u6574\u8bb2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,9],"tags":[],"class_list":["post-331","post","type-post","status-publish","format-standard","hentry","category-cad","category-ai"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/numsimlab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331"}],"version-history":[{"count":1,"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/numsimlab.com\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/numsimlab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/numsimlab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/numsimlab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}