{"id":87701,"date":"2026-07-30T18:16:32","date_gmt":"2026-07-30T10:16:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/87701.html"},"modified":"2026-07-30T18:16:32","modified_gmt":"2026-07-30T10:16:32","slug":"python-%e6%a8%a1%e5%9d%97%e6%90%9c%e7%b4%a2%e6%9c%ba%e5%88%b6sys-path%e8%af%a6%e8%a7%a3%e4%b8%8e-anaconda%e7%8e%af%e5%a2%83-%e4%be%9d%e8%b5%96%e5%86%b2%e7%aa%81%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/87701.html","title":{"rendered":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<h2>Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848<\/h2>\n<h3>\u524d\u8a00<\/h3>\n<p>\u5728\u4f7f\u7528 Anaconda \u7ba1\u7406 Python \u73af\u5883\u4f9d\u8d56\u65f6&#xff0c;\u4f60\u662f\u5426\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u60c5\u51b5&#xff1a;\u660e\u660e\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u67d0\u4e2a\u865a\u62df\u73af\u5883&#xff0c;\u4e5f\u5728\u8fd9\u4e2a\u73af\u5883\u4e2d\u7528 pip \u6216 conda \u5b89\u88c5\u597d\u4e86\u6240\u9700\u7684\u5305&#xff0c;\u4f46\u8fd0\u884c\u4ee3\u7801\u65f6\u5374\u62a5 ModuleNotFoundError&#xff0c;\u6216\u8005\u5bfc\u5165\u7684\u7adf\u7136\u662f base \u73af\u5883\u4e2d\u7684\u65e7\u7248\u672c\u5305&#xff1f;<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u80cc\u540e&#xff0c;\u5f80\u5f80\u4e0e Python \u7684\u6a21\u5757\u641c\u7d22\u673a\u5236 \u2014\u2014 \u5c24\u5176\u662f sys.path \u7684\u52a0\u8f7d\u987a\u5e8f \u2014\u2014 \u5bc6\u5207\u76f8\u5173\u3002\u672c\u6587\u5c06\u6df1\u5165\u5256\u6790 Python \u6a21\u5757\u641c\u7d22\u673a\u5236\u7684\u539f\u7406&#xff0c;\u5e76\u7ed3\u5408 Anaconda \u73af\u5883\u7ba1\u7406\u7684\u5b9e\u9645\u573a\u666f&#xff0c;\u7ed9\u51fa\u7cfb\u7edf\u6027\u7684\u8bca\u65ad\u4e0e\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<h3>\u4e00\u3001Python \u6a21\u5757\u641c\u7d22\u673a\u5236&#xff1a;sys.path \u8be6\u89e3<\/h3>\n<h4>1.1 \u4ec0\u4e48\u662f sys.path&#xff1f;<\/h4>\n<p>\u5f53\u4f60\u5199\u4e0b import xxx \u65f6&#xff0c;Python \u89e3\u91ca\u5668\u4f1a\u6309\u7167\u4e00\u5b9a\u7684\u987a\u5e8f\u5728\u591a\u4e2a\u76ee\u5f55\u4e2d\u67e5\u627e\u5bf9\u5e94\u7684\u6a21\u5757\u6587\u4ef6&#xff08;.py\u3001.pyc \u6216\u5305\u6587\u4ef6\u5939&#xff09;\u3002\u8fd9\u4e2a\u201c\u67e5\u627e\u76ee\u5f55\u5217\u8868\u201d\u5c31\u662f sys.path\u3002<\/p>\n<p>sys.path \u662f\u4e00\u4e2a\u666e\u901a\u7684 Python \u5217\u8868&#xff0c;\u5176\u4e2d\u7684\u8def\u5f84\u987a\u5e8f\u76f4\u63a5\u51b3\u5b9a\u4e86\u6a21\u5757\u7684\u67e5\u627e\u4f18\u5148\u7ea7\u2014\u2014Python \u4f1a\u6309\u5217\u8868\u987a\u5e8f\u4f9d\u6b21\u67e5\u627e&#xff0c;\u627e\u5230\u7b2c\u4e00\u4e2a\u5339\u914d\u7684\u6a21\u5757\u540e\u5c31\u505c\u6b62\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u67e5\u770b\u5f53\u524d\u73af\u5883\u7684\u6a21\u5757\u641c\u7d22\u8def\u5f84&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> sys<br \/>\n<span class=\"token keyword\">for<\/span> path <span class=\"token keyword\">in<\/span> sys<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">)<\/span><\/p>\n<h4>1.2 sys.path \u7684\u521d\u59cb\u5316\u987a\u5e8f<\/h4>\n<p>Python \u89e3\u91ca\u5668\u542f\u52a8\u65f6&#xff0c;sys.path \u4f1a\u6309\u4ee5\u4e0b\u987a\u5e8f\u88ab\u586b\u5145&#xff1a;<\/p>\n<table>\n<tr>\u4f18\u5148\u7ea7\u8def\u5f84\u6765\u6e90\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6700\u9ad8<\/td>\n<td>\u5f53\u524d\u811a\u672c\u6240\u5728\u76ee\u5f55&#xff08;\u6216\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55&#xff09;<\/td>\n<td>\u6267\u884c python script.py \u65f6&#xff0c;\u7b2c\u4e00\u9879\u4e3a\u811a\u672c\u6240\u5728\u76ee\u5f55&#xff1b;\u4ea4\u4e92\u5f0f shell \u6216 -c \u547d\u4ee4\u65f6&#xff0c;\u7b2c\u4e00\u9879\u4e3a\u7a7a\u5b57\u7b26\u4e32&#xff08;\u8868\u793a\u5f53\u524d\u76ee\u5f55&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8<\/td>\n<td>PYTHONPATH \u73af\u5883\u53d8\u91cf<\/td>\n<td>\u7528\u6237\u53ef\u914d\u7f6e\u7684\u8def\u5f84\u5217\u8868&#xff0c;\u4f18\u5148\u7ea7\u4ec5\u6b21\u4e8e\u5f53\u524d\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d<\/td>\n<td>site-packages \u76ee\u5f55\u53ca .pth \u6587\u4ef6<\/td>\n<td>pip\/conda \u5b89\u88c5\u7684\u7b2c\u4e09\u65b9\u5305\u6240\u5728\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u6700\u4f4e<\/td>\n<td>Python \u6807\u51c6\u5e93\u8def\u5f84<\/td>\n<td>\u7cfb\u7edf\u7ea7\u522b\u7684\u6807\u51c6\u5e93\u4f4d\u7f6e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.3 \u6a21\u5757\u5bfc\u5165\u7684\u5b8c\u6574\u6d41\u7a0b<\/h4>\n<p>\u4e00\u6b21\u5b8c\u6574\u7684\u6a21\u5757\u5bfc\u5165&#xff0c;\u5b9e\u9645\u4e0a\u7ecf\u5386\u4e86\u4ee5\u4e0b\u9636\u6bb5&#xff1a;<\/p>\n<li>\u7f13\u5b58\u68c0\u67e5&#xff1a;\u89e3\u91ca\u5668\u9996\u5148\u67e5\u8be2 sys.modules \u7f13\u5b58&#xff0c;\u5982\u679c\u6a21\u5757\u5df2\u88ab\u52a0\u8f7d\u5219\u76f4\u63a5\u8fd4\u56de&#xff0c;\u907f\u514d\u91cd\u590d\u52a0\u8f7d\u3002<\/li>\n<li>\u5143\u8def\u5f84\u67e5\u627e&#xff1a;\u82e5\u7f13\u5b58\u672a\u547d\u4e2d&#xff0c;\u904d\u5386 sys.meta_path \u4e2d\u7684\u67e5\u627e\u5668&#xff08;finder&#xff09;\u5bf9\u8c61\u3002\u9ed8\u8ba4\u67e5\u627e\u5668\u5305\u62ec&#xff1a;\u5185\u5efa\u6a21\u5757\u67e5\u627e\u5668 \u2192 \u51bb\u7ed3\u6a21\u5757\u67e5\u627e\u5668 \u2192 \u57fa\u4e8e sys.path \u7684\u8def\u5f84\u67e5\u627e\u5668\u3002<\/li>\n<li>\u8def\u5f84\u641c\u7d22&#xff1a;\u8def\u5f84\u67e5\u627e\u5668\u904d\u5386 sys.path \u4e2d\u7684\u6bcf\u4e2a\u76ee\u5f55&#xff0c;\u5bfb\u627e\u5339\u914d\u7684\u6a21\u5757\u6587\u4ef6\u3002<\/li>\n<li>\u52a0\u8f7d\u6267\u884c&#xff1a;\u627e\u5230\u6a21\u5757\u540e&#xff0c;\u7531\u5bf9\u5e94\u7684\u52a0\u8f7d\u5668&#xff08;loader&#xff09;\u8d1f\u8d23\u52a0\u8f7d\u5e76\u6267\u884c\u6a21\u5757\u4ee3\u7801\u3002<\/li>\n<h4>1.4 \u52a8\u6001\u4fee\u6539 sys.path \u7684\u51e0\u79cd\u65b9\u5f0f<\/h4>\n<p>\u867d\u7136\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u901a\u8fc7 sys.path.append() \u6216 sys.path.insert() \u52a8\u6001\u6dfb\u52a0\u8def\u5f84&#xff0c;\u4f46\u8fd9\u79cd\u65b9\u6cd5\u4ec5\u9002\u7528\u4e8e\u4e34\u65f6\u8c03\u8bd5&#xff0c;\u4e0d\u63a8\u8350\u957f\u671f\u4f7f\u7528&#xff0c;\u5e94\u4f18\u5148\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u548c\u6b63\u786e\u7684\u5305\u7ed3\u6784\u3002<\/p>\n<p>\u66f4\u89c4\u8303\u7684\u8def\u5f84\u7ba1\u7406\u65b9\u5f0f\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>PYTHONPATH \u73af\u5883\u53d8\u91cf&#xff1a;\u5728\u7cfb\u7edf\u6216\u7528\u6237\u7ea7\u522b\u914d\u7f6e\u6a21\u5757\u641c\u7d22\u8def\u5f84<\/li>\n<li>.pth \u6587\u4ef6&#xff1a;\u5728 site-packages \u76ee\u5f55\u4e0b\u521b\u5efa .pth \u6587\u4ef6&#xff0c;\u6bcf\u884c\u4e00\u4e2a\u8def\u5f84&#xff0c;Python \u542f\u52a8\u65f6\u4f1a\u81ea\u52a8\u5c06\u5176\u52a0\u5165 sys.path<\/li>\n<\/ul>\n<h3>\u4e8c\u3001Anaconda \u73af\u5883\u4e2d\u7684\u4f9d\u8d56\u51b2\u7a81&#xff1a;\u95ee\u9898\u6839\u6e90<\/h3>\n<h4>2.1 \u5178\u578b\u95ee\u9898\u573a\u666f<\/h4>\n<p>\u5728\u4f7f\u7528 Anaconda \u7ba1\u7406\u591a\u4e2a Python \u73af\u5883\u65f6&#xff0c;\u6700\u5e38\u89c1\u7684\u51b2\u7a81\u573a\u666f\u5305\u62ec&#xff1a;<\/p>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e&#xff0c;\u5bfc\u5165\u7684\u5374\u662f base \u73af\u5883\u7684\u5305&#xff1a;\u660e\u660e conda activate my_env \u6210\u529f\u4e86&#xff0c;\u4f46 import some_package \u52a0\u8f7d\u7684\u5374\u662f base \u73af\u5883\u4e2d\u7684\u7248\u672c\u3002<\/p>\n<\/li>\n<li>\n<p>pip \u5b89\u88c5\u7684\u5305\u6ca1\u6709\u5b89\u88c5\u5230\u6b63\u786e\u7684\u73af\u5883&#xff1a;\u5728\u865a\u62df\u73af\u5883\u4e2d\u6267\u884c pip install&#xff0c;\u5305\u5374\u88ab\u5b89\u88c5\u5230\u4e86 base \u73af\u5883\u7684 site-packages \u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u540c\u73af\u5883\u95f4\u7684\u8def\u5f84\u76f8\u4e92\u6c61\u67d3&#xff1a;base \u73af\u5883\u7684\u8def\u5f84\u88ab\u9519\u8bef\u5730\u4fdd\u7559\u5728\u4e86\u865a\u62df\u73af\u5883\u7684 sys.path \u4e2d\u3002<\/p>\n<\/li>\n<h4>2.2 \u6839\u672c\u539f\u56e0\u5206\u6790<\/h4>\n<p>\u8fd9\u4e9b\u95ee\u9898\u7684\u6839\u6e90&#xff0c;\u53ef\u4ee5\u5f52\u7ed3\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762&#xff1a;<\/p>\n<p>&#xff08;1&#xff09;PYTHONPATH \u73af\u5883\u53d8\u91cf\u7684\u201c\u9057\u6bd2\u201d<\/p>\n<p>\u5982\u679c\u5728 ~\/.bashrc \u6216\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u8bbe\u7f6e\u4e86 PYTHONPATH&#xff0c;\u8fd9\u4e2a\u8def\u5f84\u4f1a\u88ab\u6240\u6709 Python \u73af\u5883\u7ee7\u627f\u3002\u7531\u4e8e PYTHONPATH \u5728 sys.path \u4e2d\u7684\u4f18\u5148\u7ea7\u5f88\u9ad8&#xff08;\u4ec5\u6b21\u4e8e\u5f53\u524d\u76ee\u5f55&#xff09;&#xff0c;\u5b83\u4f1a\u5bfc\u81f4\u6240\u6709\u865a\u62df\u73af\u5883\u90fd\u4f18\u5148\u4ece\u8be5\u8def\u5f84\u52a0\u8f7d\u6a21\u5757&#xff0c;\u4ece\u800c\u9020\u6210\u7248\u672c\u6df7\u4e71\u3002<\/p>\n<p>\u5173\u952e\u70b9&#xff1a;Conda \u5b98\u65b9\u63a8\u8350\u5728 conda \u73af\u5883\u4e2d\u907f\u514d\u4f7f\u7528 PYTHONPATH&#xff0c;\u56e0\u4e3a\u8fd9\u4f1a\u7834\u574f\u73af\u5883\u7684\u9694\u79bb\u6027\u3002<\/p>\n<p>&#xff08;2&#xff09;pip install &#8211;user \u7684\u5e72\u6270<\/p>\n<p>\u4f7f\u7528 pip install &#8211;user \u4f1a\u5c06\u5305\u5b89\u88c5\u5230\u7528\u6237\u7ea7\u7684 site-packages \u76ee\u5f55&#xff08;\u5982 ~\/.local\/lib\/python3.x\/site-packages&#xff09;\u3002\u7531\u4e8e site \u6a21\u5757\u5728\u521d\u59cb\u5316\u65f6\u4f1a\u5c06\u7528\u6237\u7ea7 site-packages \u8ffd\u52a0\u5230 sys.path \u4e2d&#xff0c;\u8fd9\u4f1a\u5bfc\u81f4\u6240\u6709\u73af\u5883\u90fd\u201c\u770b\u5230\u201d\u8fd9\u4e9b\u7528\u6237\u7ea7\u5305&#xff0c;\u9020\u6210\u51b2\u7a81\u3002<\/p>\n<p>&#xff08;3&#xff09;PYTHONHOME \u7684\u9519\u8bef\u8bbe\u7f6e<\/p>\n<p>PYTHONHOME \u73af\u5883\u53d8\u91cf\u4f1a\u6539\u53d8 Python \u89e3\u91ca\u5668\u67e5\u627e\u6807\u51c6\u5e93\u7684\u6839\u76ee\u5f55\u3002\u5982\u679c\u9519\u8bef\u5730\u8bbe\u7f6e\u4e86 PYTHONHOME&#xff0c;\u4e0d\u4ec5\u4f1a\u5bfc\u81f4\u6a21\u5757\u5bfc\u5165\u6df7\u4e71&#xff0c;\u8fd8\u53ef\u80fd\u4f7f pip \u7b49\u5de5\u5177\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>&#xff08;4&#xff09;Conda \u73af\u5883\u4e0e pip \u7684\u201c\u6469\u64e6\u201d<\/p>\n<p>\u5f53\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 conda \u73af\u5883\u65f6&#xff0c;Anaconda \u5e76\u4e0d\u4f1a\u4e3a\u8fd9\u4e2a\u73af\u5883\u751f\u6210\u4e00\u4e2a\u5b8c\u5168\u72ec\u7acb\u7684 pip \u914d\u7f6e\u6587\u4ef6\u3002\u65b0\u73af\u5883\u4e2d\u7684 pip \u53ef\u80fd\u4f1a\u201c\u60ef\u6027\u201d\u5730\u6307\u5411 base \u73af\u5883\u7684 site-packages\u3002\u8fd9\u5bfc\u81f4\u5728\u865a\u62df\u73af\u5883\u4e2d\u6267\u884c pip install \u65f6&#xff0c;\u5305\u53ef\u80fd\u88ab\u5b89\u88c5\u5230\u9519\u8bef\u7684\u4f4d\u7f6e\u3002<\/p>\n<h3>\u4e09\u3001\u8bca\u65ad\u4e0e\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>3.1 \u8bca\u65ad\u5de5\u5177\u4e0e\u547d\u4ee4<\/h4>\n<p>\u5728\u89e3\u51b3\u95ee\u9898\u4e4b\u524d&#xff0c;\u9996\u5148\u8981\u51c6\u786e\u8bca\u65ad\u5f53\u524d\u72b6\u6001\u3002\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5feb\u901f\u5b9a\u4f4d\u95ee\u9898&#xff1a;<br \/>\n\u4ee5\u4e0b\u64cd\u4f5c\u5728 Anaconda Prompt  \u4e2d\u6267\u884c<\/p>\n<p>\u67e5\u770b\u5f53\u524d Python \u89e3\u91ca\u5668\u8def\u5f84&#xff1a;<\/p>\n<p><span class=\"token comment\"># Linux\/macOS<\/span><br \/>\n<span class=\"token function\">which<\/span> python<br \/>\n<span class=\"token comment\"># Windows<\/span><br \/>\nwhere python<\/p>\n<p>\u786e\u4fdd\u8f93\u51fa\u8def\u5f84\u6307\u5411\u5f53\u524d\u6fc0\u6d3b\u7684 conda \u73af\u5883\u76ee\u5f55\u3002<\/p>\n<p>\u67e5\u770b sys.path \u7684\u5b8c\u6574\u5185\u5bb9&#xff1a;<\/p>\n<p>python <span class=\"token parameter variable\">-c<\/span> <span class=\"token string\">&#034;import sys; print(&#039;<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>&#039;.join(sys.path))&#034;<\/span><\/p>\n<p>\u68c0\u67e5\u5217\u8868\u4e2d\u662f\u5426\u5305\u542b\u975e\u9884\u671f\u8def\u5f84&#xff08;\u5982 base \u73af\u5883\u7684 site-packages\u3001\u7cfb\u7edf Python \u8def\u5f84\u3001\u7528\u6237\u7ea7 site-packages \u7b49&#xff09;\u3002<\/p>\n<p>\u67e5\u770b PYTHONPATH \u73af\u5883\u53d8\u91cf&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token variable\">$PYTHONPATH<\/span>   <span class=\"token comment\"># Linux\/macOS<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> %PYTHONPATH%  <span class=\"token comment\"># Windows<\/span><\/p>\n<p>\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e2d\u7684 pip \u6307\u5411&#xff1a;<\/p>\n<p>where pip   <span class=\"token comment\"># \u6216 which pip <\/span><br \/>\npip <span class=\"token parameter variable\">-V<\/span>      <span class=\"token comment\"># \u663e\u793a pip \u7684\u5b89\u88c5\u4f4d\u7f6e<\/span><\/p>\n<p>\u5982\u679c pip -V \u663e\u793a\u7684\u8def\u5f84\u4e0d\u662f\u5f53\u524d conda \u73af\u5883\u7684\u8def\u5f84&#xff0c;\u8bf4\u660e pip \u6307\u5411\u9519\u8bef\u3002<\/p>\n<h4>3.2 \u89e3\u51b3\u65b9\u6848\u6c47\u603b<\/h4>\n<h5>\u65b9\u6848\u4e00&#xff1a;\u6e05\u7406\u73af\u5883\u53d8\u91cf&#xff08;\u6700\u4f18\u5148&#xff09;<\/h5>\n<p>\u68c0\u67e5\u5e76\u6e05\u7406 PYTHONPATH \u548c PYTHONHOME&#xff1a;<\/p>\n<p>\u8fd9\u662f\u89e3\u51b3 sys.path \u6df7\u4e71\u7684\u6700\u9ad8\u4f18\u5148\u7ea7\u64cd\u4f5c\u3002<\/p>\n<ul>\n<li>\n<p>\u9a8c\u8bc1\u65b9\u6cd5&#xff08;\u67e5\u770b\u662f\u5426\u5b58\u5728&#xff09;&#xff1a;<br \/>\n\u6253\u5f00 Anaconda Prompt \u6216 CMD \u8f93\u5165&#xff1a;<\/p>\n<p>echo %PYTHONPATH%<br \/>\necho %PYTHONHOME%<\/p>\n<p>\u5982\u679c\u8fd4\u56de\u7684\u662f %PYTHONPATH%&#xff08;\u539f\u6837\u8f93\u51fa&#xff09;\u6216\u7a7a\u767d&#xff0c;\u8bf4\u660e\u5f53\u524d\u7a97\u53e3\u6ca1\u6709\u8bbe\u7f6e&#xff0c;\u662f\u5e72\u51c0\u7684\u3002\u5982\u679c\u8fd4\u56de\u4e86\u4e00\u4e2a\u5177\u4f53\u7684\u6587\u4ef6\u5939\u8def\u5f84&#xff08;\u5982 C:\\\\Users\\\\YourName\\\\my_packages&#xff09;&#xff0c;\u8bf4\u660e\u88ab\u6c61\u67d3\u4e86\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e34\u65f6\u6e05\u7406&#xff08;\u4ec5\u5f53\u524d CMD \u7a97\u53e3\u751f\u6548&#xff09;&#xff1a;<br \/>\n\u76f4\u63a5\u5728\u7ec8\u7aef\u6267\u884c&#xff1a;<\/p>\n<p>set PYTHONPATH&#061;<br \/>\nset PYTHONHOME&#061;<\/p>\n<p>&#xff08;\u6ce8\u610f&#xff1a;\u7b49\u53f7\u540e\u9762\u4ec0\u4e48\u90fd\u4e0d\u8981\u5199&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u6c38\u4e45\u6e05\u7406&#xff08;\u63a8\u8350&#xff0c;\u4e00\u52b3\u6c38\u9038&#xff09;&#xff1a;<br \/>\n\u5728 Windows \u4e2d&#xff0c;\u6c38\u4e45\u53d8\u91cf\u5b58\u50a8\u5728\u6ce8\u518c\u8868\u4e2d&#xff0c;\u5343\u4e07\u4e0d\u8981\u5728 CMD \u91cc\u7528 setx \u4e71\u6539&#xff08;\u5bb9\u6613\u6b8b\u7559\u7a7a\u503c&#xff09;\u3002\u6700\u7a33\u59a5\u7684\u65b9\u6cd5\u662f&#xff1a;<\/p>\n<li>\u6309 Win &#043; R&#xff0c;\u8f93\u5165 sysdm.cpl \u5e76\u56de\u8f66\u3002<\/li>\n<li>\u70b9\u51fb \u201c\u9ad8\u7ea7\u201d \u9009\u9879\u5361 \u2192 \u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728 \u201c\u7528\u6237\u53d8\u91cf\u201d \u548c \u201c\u7cfb\u7edf\u53d8\u91cf\u201d \u4e24\u4e2a\u5217\u8868\u4e2d&#xff0c;\u9010\u4e00\u70b9\u51fb PYTHONPATH \u548c PYTHONHOME&#xff0c;\u7136\u540e\u70b9\u51fb\u201c\u5220\u9664\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u786e\u5b9a\u4fdd\u5b58\u3002\u5fc5\u987b\u91cd\u65b0\u6253\u5f00\u4e00\u4e2a\u65b0\u7684 CMD \/ Anaconda Prompt \u7a97\u53e3&#xff0c;\u5220\u9664\u624d\u4f1a\u751f\u6548\u3002<\/li>\n<\/li>\n<\/ul>\n<h5>\u65b9\u6848\u4e8c&#xff1a;\u6e05\u7406\u7528\u6237\u7ea7 site-packages(\u5904\u7406 pip &#8211;user \u540e\u9057\u75c7)<\/h5>\n<p>\u5982\u679c\u4e4b\u524d\u4f7f\u7528\u8fc7 pip install &#8211;user&#xff0c;\u7528\u6237\u7ea7 site-packages \u4e2d\u7684\u5305\u53ef\u80fd\u4f1a\u6c61\u67d3\u6240\u6709\u73af\u5883\u3002<\/p>\n<ul>\n<li>\n<p>\u9a8c\u8bc1\u65b9\u6cd5&#xff08;\u627e\u51fa\u6c61\u67d3\u6e90\u4f4d\u7f6e&#xff09;&#xff1a;<br \/>\n\u5728 Anaconda Prompt \u4e2d\u6267\u884c&#xff1a;<\/p>\n<p>python -m site &#8211;user-site<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u8f93\u51fa\u8def\u5f84\u5e94\u8be5\u5305\u542b AppData\\\\Roaming\\\\Python\u3002\u5982\u679c\u8fd9\u4e2a\u8def\u5f84\u4e0b\u5b58\u5728\u5927\u91cf\u4f60\u5e76\u4e0d\u60f3\u5728\u5168\u5c40\u4f7f\u7528\u7684\u7b2c\u4e09\u65b9\u5305&#xff08;\u5982 numpy\u3001pandas&#xff09;&#xff0c;\u5c31\u8bf4\u660e\u5b83\u53ef\u80fd\u6c61\u67d3\u4e86\u4f60\u7684 conda \u73af\u5883\u3002<\/p>\n<\/li>\n<li>\n<p>\u6267\u884c\u64cd\u4f5c&#xff1a;<\/p>\n<li>\u590d\u5236\u4e0a\u4e00\u6b65\u8f93\u51fa\u7684\u8def\u5f84&#xff0c;\u5728\u6587\u4ef6\u8d44\u6e90\u7ba1\u7406\u5668\u4e2d\u6253\u5f00\u3002<\/li>\n<li>\u4e0d\u5efa\u8bae\u76f4\u63a5\u5220\u6574\u4e2a\u6587\u4ef6\u5939&#xff08;\u53ef\u80fd\u4f1a\u5220\u6389\u7cfb\u7edf\u7f13\u5b58&#xff09;\u3002\u5efa\u8bae\u53ea\u5220\u9664\u91cc\u9762\u5177\u4f53\u7684\u5305\u6587\u4ef6\u5939&#xff08;\u5982 numpy\u3001scipy \u6587\u4ef6\u5939&#xff09;\u548c .dist-info \u7ed3\u5c3e\u7684\u6587\u4ef6\u5939\u3002<\/li>\n<li>\u5982\u679c\u4f60\u5206\u4e0d\u6e05\u54ea\u4e9b\u8be5\u5220&#xff0c;\u6700\u4fdd\u9669\u7684\u505a\u6cd5\u662f\u5c06\u6574\u4e2a site-packages \u6587\u4ef6\u5939\u91cd\u547d\u540d&#xff08;\u4f8b\u5982\u6539\u6210 site-packages_backup&#xff09;\u3002\u8fd9\u6837 Python \u5c31\u627e\u4e0d\u5230\u5b83\u4e86&#xff0c;\u5982\u679c\u540e\u7eed\u53d1\u73b0\u6ca1\u95ee\u9898&#xff0c;\u518d\u5f7b\u5e95\u5220\u9664\u3002<\/li>\n<\/li>\n<\/ul>\n<h5>\u65b9\u6848\u4e09&#xff1a;\u5728 Conda \u73af\u5883\u4e2d\u6b63\u786e\u4f7f\u7528 pip<\/h5>\n<p>\u4e0d\u8981\u6df7\u7528 conda install \u548c pip install \u5b89\u88c5\u540c\u4e00\u4e2a\u5305\u7684\u4e0d\u540c\u7248\u672c&#xff0c;\u8fd9\u51e0\u4e4e\u5fc5\u7136\u5bfc\u81f4\u4f9d\u8d56\u51b2\u7a81\u3002<\/p>\n<p>\u63a8\u8350\u7684\u505a\u6cd5\u662f&#xff1a;<\/p>\n<li>\u4f18\u5148\u4f7f\u7528 conda install&#xff08;conda \u80fd\u66f4\u597d\u5730\u89e3\u6790\u8de8\u8bed\u8a00\u4f9d\u8d56&#xff09;<\/li>\n<li>\u5982\u679c\u5fc5\u987b\u4f7f\u7528 pip&#xff0c;\u786e\u4fdd\u5728\u6fc0\u6d3b\u7684 conda \u73af\u5883\u4e2d\u6267\u884c&#xff0c;\u5e76\u4e14\u4e0d\u8981\u4f7f\u7528 &#8211;user \u53c2\u6570<\/li>\n<li>\u4f7f\u7528 environment.yml \u6587\u4ef6\u7edf\u4e00\u7ba1\u7406\u73af\u5883\u4f9d\u8d56<\/li>\n<p>\u9a8c\u8bc1 pip \u662f\u5426\u6b63\u786e\u6307\u5411\u5f53\u524d\u73af\u5883&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5728\u6fc0\u6d3b\u7684 conda \u73af\u5883\u4e2d<\/span><br \/>\npip <span class=\"token parameter variable\">-V<\/span><br \/>\n<span class=\"token comment\"># \u5e94\u8be5\u663e\u793a\u7c7b\u4f3c&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># pip 23.x from \/path\/to\/anaconda3\/envs\/my_env\/lib\/python3.x\/site-packages\/pip<\/span><\/p>\n<p>\u5982\u679c pip \u6307\u5411\u9519\u8bef&#xff0c;\u53ef\u4ee5\u5c1d\u8bd5&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5728\u5f53\u524d\u73af\u5883\u4e2d\u91cd\u65b0\u5b89\u88c5 pip<\/span><br \/>\nconda <span class=\"token function\">install<\/span> pip<br \/>\n<span class=\"token comment\"># \u6216<\/span><br \/>\npython <span class=\"token parameter variable\">-m<\/span> pip <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">&#8211;upgrade<\/span> pip<\/p>\n<h5>\u65b9\u6848\u56db&#xff1a;\u4f7f\u7528 .pth \u6587\u4ef6\u7ba1\u7406\u81ea\u5b9a\u4e49\u8def\u5f84(Windows \u8def\u5f84\u5199\u6cd5)<\/h5>\n<p>\u5982\u679c\u4f60\u6709\u81ea\u5b9a\u4e49\u7684\u6a21\u5757\u76ee\u5f55\u9700\u8981\u52a0\u5165\u641c\u7d22\u8def\u5f84&#xff0c;\u63a8\u8350\u4f7f\u7528 .pth \u6587\u4ef6\u800c\u4e0d\u662f PYTHONPATH&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8fdb\u5165 site-packages \u76ee\u5f55&#xff1a;<br \/>\n\u5728 CMD \u4e2d&#xff0c;\u5229\u7528 Python \u52a8\u6001\u83b7\u53d6\u8def\u5f84\u5e76\u8fdb\u5165&#xff08;\u6ce8\u610f Windows \u4e0b\u4f7f\u7528 for \u547d\u4ee4&#xff09;&#xff1a;<\/p>\n<p>for \/f &#034;delims&#061;&#034; %i in (&#039;python -c &#034;import site; print(site.getsitepackages()[0])&#034;&#039;) do cd &#034;%i&#034;<\/p>\n<p>&#xff08;\u5982\u679c\u4f60\u7528\u7684\u662f PowerShell&#xff0c;\u547d\u4ee4\u4e3a&#xff1a;cd $(python -c &#034;import site; print(site.getsitepackages()[0])&#034;)&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u6267\u884c\u64cd\u4f5c&#xff1a;<br \/>\n\u5728\u5f53\u524d\u8def\u5f84\u4e0b\u521b\u5efa\u4e00\u4e2a .pth \u6587\u4ef6\u3002\u6ce8\u610f Windows \u8def\u5f84\u8981\u4f7f\u7528\u53cc\u53cd\u659c\u6760 \\\\\\\\ \u6216\u6b63\u659c\u6760 \/\u3002<\/p>\n<p>echo C:\/path\/to\/your\/custom\/modules &gt; my_custom_paths.pth<\/p>\n<p>&#xff08;\u8bf7\u5c06 C:\/path\/to\/your\/custom\/modules \u66ff\u6362\u4e3a\u4f60\u5b9e\u9645\u7684\u6587\u4ef6\u5939\u8def\u5f84&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u6837&#xff0c;\u81ea\u5b9a\u4e49\u8def\u5f84\u53ea\u5bf9\u5f53\u524d\u73af\u5883\u751f\u6548&#xff0c;\u4e0d\u4f1a\u6c61\u67d3\u5176\u4ed6\u73af\u5883\u3002<\/p>\n<h5>\u65b9\u6848\u4e94&#xff1a;\u4f7f\u7528 conda develop \u547d\u4ee4&#xff08;\u63a8\u8350&#xff09;<\/h5>\n<p>Conda \u63d0\u4f9b\u4e86 conda develop \u547d\u4ee4&#xff0c;\u53ef\u4ee5\u5c06\u5f00\u53d1\u4e2d\u7684\u9879\u76ee\u76ee\u5f55\u6dfb\u52a0\u5230\u5f53\u524d\u73af\u5883\u7684 sys.path \u4e2d&#xff1a;<\/p>\n<p>conda develop \/path\/to\/your\/project<\/p>\n<p>\u8fd9\u76f8\u5f53\u4e8e\u5728\u5f53\u524d\u73af\u5883\u7684 site-packages \u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a .pth \u6587\u4ef6&#xff0c;\u662f\u7ba1\u7406\u5f00\u53d1\u9879\u76ee\u4f9d\u8d56\u7684\u63a8\u8350\u65b9\u5f0f\u3002<\/p>\n<h5>\u65b9\u6848\u516d&#xff1a;\u91cd\u5efa\u73af\u5883&#xff08;\u7ec8\u6781\u65b9\u6848&#xff09;<\/h5>\n<p>\u5982\u679c\u73af\u5883\u5df2\u7ecf\u88ab\u4e25\u91cd\u6c61\u67d3&#xff0c;\u6700\u5f7b\u5e95\u7684\u89e3\u51b3\u65b9\u5f0f\u662f\u91cd\u5efa\u73af\u5883&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5bfc\u51fa\u5f53\u524d\u73af\u5883\u7684\u4f9d\u8d56\u5217\u8868&#xff08;\u4ec5 conda \u5305&#xff09;<\/span><br \/>\nconda <span class=\"token function\">env<\/span> <span class=\"token builtin class-name\">export<\/span> &#8211;no-builds <span class=\"token operator\">&gt;<\/span> environment.yml<\/p>\n<p><span class=\"token comment\"># \u6216\u5bfc\u51fa\u5305\u542b pip \u5305\u7684\u5b8c\u6574\u4f9d\u8d56<\/span><br \/>\nconda <span class=\"token function\">env<\/span> <span class=\"token builtin class-name\">export<\/span> <span class=\"token operator\">&gt;<\/span> environment_full.yml<\/p>\n<p><span class=\"token comment\"># \u5220\u9664\u65e7\u73af\u5883<\/span><br \/>\nconda <span class=\"token function\">env<\/span> remove <span class=\"token parameter variable\">-n<\/span> my_env<\/p>\n<p><span class=\"token comment\"># \u4ece yml \u6587\u4ef6\u91cd\u5efa<\/span><br \/>\nconda <span class=\"token function\">env<\/span> create <span class=\"token parameter variable\">-f<\/span> environment.yml<\/p>\n<h4>3.3 \u9884\u9632\u63aa\u65bd<\/h4>\n<li>\u4e0d\u8981\u5728\u5168\u5c40\u914d\u7f6e\u4e2d\u8bbe\u7f6e PYTHONPATH&#xff1a;\u8fd9\u662f\u5bfc\u81f4\u73af\u5883\u9694\u79bb\u5931\u6548\u7684\u5934\u53f7\u5143\u51f6\u3002<\/li>\n<li>\u907f\u514d\u4f7f\u7528 pip install &#8211;user&#xff1a;\u5728 conda \u73af\u5883\u4e2d&#xff0c;\u59cb\u7ec8\u4f7f\u7528\u4e0d\u5e26 &#8211;user \u7684 pip install\u3002<\/li>\n<li>\u6bcf\u6b21\u521b\u5efa\u65b0\u73af\u5883\u540e&#xff0c;\u7acb\u5373\u9a8c\u8bc1&#xff1a;where python \u548c python -c &#034;import sys; print(sys.path)&#034; \u5e94\u8be5\u663e\u793a\u6b63\u786e\u7684\u73af\u5883\u8def\u5f84\u3002<\/li>\n<li>\u4f7f\u7528 environment.yml \u7ba1\u7406\u4f9d\u8d56&#xff1a;\u8fd9\u80fd\u786e\u4fdd\u73af\u5883\u5728\u4e0d\u540c\u673a\u5668\u4e0a\u7684\u4e00\u81f4\u6027\u548c\u53ef\u91cd\u73b0\u6027\u3002<\/li>\n<li>\u533a\u5206 conda install \u548c pip install \u7684\u4f7f\u7528\u573a\u666f&#xff1a;\u5c3d\u91cf\u7edf\u4e00\u4f7f\u7528 conda&#xff0c;\u5fc5\u987b\u7528 pip \u65f6\u8981\u6ce8\u610f\u7248\u672c\u9501\u5b9a\u3002<\/li>\n<h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<p>Python \u7684\u6a21\u5757\u641c\u7d22\u673a\u5236&#xff08;sys.path&#xff09;\u662f\u7406\u89e3\u73af\u5883\u4f9d\u8d56\u95ee\u9898\u7684\u6838\u5fc3\u3002\u5728 Anaconda \u591a\u73af\u5883\u7ba1\u7406\u4e2d&#xff0c;\u4f9d\u8d56\u51b2\u7a81\u7684\u6839\u672c\u539f\u56e0\u5f80\u5f80\u4e0d\u662f conda \u672c\u8eab\u7684\u95ee\u9898&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<ul>\n<li>\u73af\u5883\u53d8\u91cf&#xff08;PYTHONPATH\u3001PYTHONHOME&#xff09;\u7684\u201c\u8de8\u73af\u5883\u6c61\u67d3\u201d<\/li>\n<li>\u7528\u6237\u7ea7 site-packages \u7684\u5e72\u6270<\/li>\n<li>pip \u5728 conda \u73af\u5883\u4e2d\u7684\u8def\u5f84\u6307\u5411\u9519\u8bef<\/li>\n<\/ul>\n<p>\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u7684\u6838\u5fc3\u601d\u8def\u662f&#xff1a;\u4fdd\u6301\u73af\u5883\u7684\u7eaf\u51c0\u4e0e\u9694\u79bb\u3002\u5177\u4f53\u800c\u8a00&#xff1a;<\/p>\n<li>\u6e05\u7406&#xff1a;\u79fb\u9664 PYTHONPATH \u548c PYTHONHOME \u7b49\u5168\u5c40\u73af\u5883\u53d8\u91cf<\/li>\n<li>\u9694\u79bb&#xff1a;\u786e\u4fdd\u6bcf\u4e2a conda \u73af\u5883\u62e5\u6709\u72ec\u7acb\u7684 site-packages&#xff0c;\u4e0d\u88ab\u5176\u4ed6\u8def\u5f84\u5e72\u6270<\/li>\n<li>\u89c4\u8303&#xff1a;\u4f7f\u7528 conda \u6216 pip&#xff08;\u4e0d\u5e26 &#8211;user&#xff09;\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u5305<\/li>\n<li>\u9a8c\u8bc1&#xff1a;\u6bcf\u6b21\u64cd\u4f5c\u540e\u901a\u8fc7 sys.path \u68c0\u67e5\u786e\u8ba4\u8def\u5f84\u6b63\u786e<\/li>\n<p>\u7406\u89e3 sys.path \u7684\u52a0\u8f7d\u987a\u5e8f\u548c\u521d\u59cb\u5316\u673a\u5236&#xff0c;\u4e0d\u4ec5\u80fd\u5e2e\u4f60\u89e3\u51b3\u5f53\u4e0b\u7684\u4f9d\u8d56\u51b2\u7a81\u95ee\u9898&#xff0c;\u66f4\u80fd\u8ba9\u4f60\u5728\u672a\u6765\u7684\u73af\u5883\u7ba1\u7406\u4e2d\u505a\u5230\u201c\u77e5\u5176\u7136&#xff0c;\u66f4\u77e5\u5176\u6240\u4ee5\u7136\u201d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848<br \/>\n\u524d\u8a00<br \/>\n\u5728\u4f7f\u7528 Anaconda \u7ba1\u7406 Python \u73af\u5883\u4f9d\u8d56\u65f6&#xff0c;\u4f60\u662f\u5426\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u60c5\u51b5&#xff1a;\u660e\u660e\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u67d0\u4e2a\u865a\u62df\u73af\u5883&#xff0c;\u4e5f\u5728\u8fd9\u4e2a\u73af\u5883\u4e2d\u7528 pip \u6216 conda \u5b89\u88c5\u597d\u4e86\u6240\u9700\u7684\u5305&#xff0c;\u4f46\u8fd0\u884c\u4ee3\u7801\u65f6\u5374\u62a5 ModuleNotFoundError&#xff0c;\u6216\u8005\u5bfc\u5165\u7684\u7adf\u7136\u662f base \u73af\u5883\u4e2d\u7684\u65e7\u7248\u672c\u5305&#xff1f;<br \/>\n\u8fd9\u4e2a\u95ee\u9898\u80cc\u540e&amp;#xf<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[88,82,81],"topic":[],"class_list":["post-87701","post","type-post","status-publish","format-standard","hentry","category-server","tag-conda","tag-pycharm","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/87701.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 \u524d\u8a00 \u5728\u4f7f\u7528 Anaconda \u7ba1\u7406 Python \u73af\u5883\u4f9d\u8d56\u65f6&#xff0c;\u4f60\u662f\u5426\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u60c5\u51b5&#xff1a;\u660e\u660e\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u67d0\u4e2a\u865a\u62df\u73af\u5883&#xff0c;\u4e5f\u5728\u8fd9\u4e2a\u73af\u5883\u4e2d\u7528 pip \u6216 conda \u5b89\u88c5\u597d\u4e86\u6240\u9700\u7684\u5305&#xff0c;\u4f46\u8fd0\u884c\u4ee3\u7801\u65f6\u5374\u62a5 ModuleNotFoundError&#xff0c;\u6216\u8005\u5bfc\u5165\u7684\u7adf\u7136\u662f base \u73af\u5883\u4e2d\u7684\u65e7\u7248\u672c\u5305&#xff1f; \u8fd9\u4e2a\u95ee\u9898\u80cc\u540e&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/87701.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-30T10:16:32+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87701.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/87701.html\",\"name\":\"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-30T10:16:32+00:00\",\"dateModified\":\"2026-07-30T10:16:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/87701.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/87701.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87701.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/87701.html","og_locale":"zh_CN","og_type":"article","og_title":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 \u524d\u8a00 \u5728\u4f7f\u7528 Anaconda \u7ba1\u7406 Python \u73af\u5883\u4f9d\u8d56\u65f6&#xff0c;\u4f60\u662f\u5426\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u60c5\u51b5&#xff1a;\u660e\u660e\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u67d0\u4e2a\u865a\u62df\u73af\u5883&#xff0c;\u4e5f\u5728\u8fd9\u4e2a\u73af\u5883\u4e2d\u7528 pip \u6216 conda \u5b89\u88c5\u597d\u4e86\u6240\u9700\u7684\u5305&#xff0c;\u4f46\u8fd0\u884c\u4ee3\u7801\u65f6\u5374\u62a5 ModuleNotFoundError&#xff0c;\u6216\u8005\u5bfc\u5165\u7684\u7adf\u7136\u662f base \u73af\u5883\u4e2d\u7684\u65e7\u7248\u672c\u5305&#xff1f; \u8fd9\u4e2a\u95ee\u9898\u80cc\u540e&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/87701.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-30T10:16:32+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/87701.html","url":"https:\/\/www.wsisp.com\/helps\/87701.html","name":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-30T10:16:32+00:00","dateModified":"2026-07-30T10:16:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/87701.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/87701.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/87701.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python \u6a21\u5757\u641c\u7d22\u673a\u5236(sys.path)\u8be6\u89e3\u4e0e Anaconda\u73af\u5883 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=87701"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87701\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=87701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=87701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=87701"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=87701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}