{"id":1021,"date":"2021-04-09T15:18:02","date_gmt":"2021-04-09T07:18:02","guid":{"rendered":"http:\/\/www.mustenaka.cn\/?p=1021"},"modified":"2021-04-09T17:27:52","modified_gmt":"2021-04-09T09:27:52","slug":"offlineinstallpythonenvironmentandlibary","status":"publish","type":"post","link":"https:\/\/www.mustenaka.cn\/index.php\/2021\/04\/09\/offlineinstallpythonenvironmentandlibary\/","title":{"rendered":"conda\u79bb\u7ebf\u73af\u5883\u8fc1\u79fbPython\u7684\u865a\u62df\u73af\u5883\u548c\u7b2c\u4e09\u65b9\u5e93"},"content":{"rendered":"<p>\u81ea\u5df1\u7684\u5f00\u53d1\u7535\u8111\u53ef\u4ee5\u4f7f\u7528\u7f51\u7edc\uff0c\u751f\u4ea7\u7535\u8111\u4e0d\u80fd\u8054\u7f51\uff0c\u53ef\u80fd\u5c31\u9700\u8981\u7528\u5230\u79bb\u7ebf\u73af\u5883\u8fc1\u79fb\u8fd9\u4e2a\u529f\u80fd\u4e86\uff0cPython\u8bed\u8a00\u4e2d\u79bb\u7ebf\u73af\u5883\u8fc1\u79fb\u6253\u5f00\u6709\u5982\u4e0b3\u79cd\u601d\u8def\uff1a<\/p>\n<blockquote><p>1.\u76f4\u63a5\u4e0b\u8f7d\u79bb\u7ebf\u7684whl\u5305\uff0c\u5728\u76ee\u6807\u7535\u8111\u4e2d\u76f4\u63a5\u5b89\u88c5<\/p>\n<p>\u7f3a\u70b9\uff1a\u76ee\u6807\u7535\u8111\u4e2dPython\u73af\u5883\u4e0d\u540c\u5219\u5f88\u6709\u53ef\u80fd\u5931\u8d25<\/p>\n<p>2.\u5229\u7528conda\u521b\u5efa<\/p>\n<p>\u7f3a\u70b9\uff1aconda\u5b89\u88c5\u5305\u5927\uff0c\u9700\u8981\u76ee\u6807\u7535\u8111\u4e5f\u5b89\u88c5conda\uff0c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u8981\u6539\u4e00\u4e0b.bashrc\u73af\u5883\u53d8\u91cf<\/p>\n<p>3.\u76f4\u63a5\u5229\u7528Python\u81ea\u5e26\u7684\u865a\u62df\u73af\u5883\u7ba1\u7406<\/p>\n<p>\u7f3a\u70b9\uff1a\u65e0\u6cd5\u4fee\u6539Python\u7248\u672c\uff0c\u73af\u5883\u56fa\u5b9a<\/p><\/blockquote>\n<p>\u4f46\u662f\u7528conda\u7684\u4f18\u70b9\u5219\u662f\uff0c\u53ef\u4ee5\u9009\u62e9Python\u7248\u672c\u73af\u5883\uff0c\u4fee\u6539\u73af\u5883\u53d8\u5f97\u76f8\u5f53\u5bb9\u6613\uff0c\u53ea\u9700\u8981\u652f\u6301tar.gz\u683c\u5f0f\u7684\u89e3\u538b\u5373\u53ef\u4f7f\u7528\u4e0d\u540c\u73af\u5883\u3002<\/p>\n<p>\u800c\u4e14\uff0c\u5728\u81ea\u5df1\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u6709\u7f51\u7edc\uff0c\u76f4\u63a5\u5229\u7528\u7f51\u7edcpip install\u547d\u4ee4\u6216\u8005conda install\u547d\u4ee4\u5728\u7ebf\u5b89\u88c5\u73af\u5883\uff0c\u7136\u540econda pack\u547d\u4ee4\u73af\u5883\u5bfc\u51fa\uff0c\u4e0d\u518d\u9700\u8981\u81ea\u5df1\u624b\u52a8\u53bb\u4e0b\u8f7d\u54ea\u4e9b\u5305\u4e86\uff0c\u5230\u65f6\u5019\u5728\u76ee\u6807\u4e3b\u673a\u4e0a\u76f4\u63a5\u89e3\u538b\u5c31\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u865a\u62df\u73af\u5883\u4e86\u3002<\/p>\n<h3>\u4e00\u3001\u5c06\u8981\u8fc1\u79fb\u73af\u5883\u6253\u5305\u538b\u7f29<\/h3>\n<p>\u9996\u5148\u8fdb\u5165\u6b63\u5728\u5f00\u53d1\u7684\u73af\u5883\uff0c\u5728\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528\u8f93\u5165<\/p>\n<blockquote><p>conda pack -n venv_name -o output_name.tar.gz<\/p><\/blockquote>\n<p>\u5982\u679c\u63d0\u793aNo command &#8216;conda pack&#8217;\uff0c\u6216\u8005\u8bf4\u662f\u5426\u547d\u4ee4\u6b63\u786e<\/p>\n<p>\u5219\u5c1d\u8bd5\u4f7f\u7528<\/p>\n<blockquote><p>conda install -c conda-forge conda-pack<\/p><\/blockquote>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\u91cd\u65b0\u8fdb\u884c\u6253\u5305\u3002<\/p>\n<h3>\u4e8c\u3001\u4e0a\u4f20\u8fc1\u79fb\u73af\u5883<\/h3>\n<p>U\u76d8\u62f7\u8d1d\u4e5f\u597d\uff0c\u5149\u76d8\u590d\u5236\u4e5f\u7f62\uff0cscp\u547d\u4ee4\u4e5f\u597d\uff0cftp\u547d\u4ee4\u4e5f\u7f62\uff0c\u628a\u5bfc\u51fa\u7684output_name.tar.gz\u60f3\u4e2a\u529e\u6cd5\u653e\u5230\u76ee\u6807\u670d\u52a1\u5668\u4e2d\u3002<\/p>\n<h3>\u4e09\u3001\u5728\u76ee\u6807\u7535\u8111\u4e0b\u5b89\u88c5<\/h3>\n<p>macOS\u7684\u76ee\u5f55\u5728 ~\/opt\/miniconda\/envs\/\uff08\u5982\u679c\u4f7f\u7528anaconda\u5219\u628aminiconda\u66ff\u6362\u5373\u53ef\uff09<\/p>\n<p>mkdir\u521b\u5efa\u4e00\u4e2a\u7a7a\u6587\u4ef6\u5939\uff0c\u5982mkdir tmpenv<\/p>\n<blockquote><p>tar -xzvf <span>output_name.tar.gz -C Anaconda3<\/span><span class=\"hljs-regexp\">\/envs\/tmpenv\/<\/span><\/p><\/blockquote>\n<p>\u89e3\u538b\u5b8c\u6210\u5373\u6210\u529f<\/p>\n<p>\u6b64\u65f6\u8f93\u5165<\/p>\n<p>conda env list \u6216\u8005 conda info &#8211;env<\/p>\n<p>\u5df2\u7ecf\u53ef\u4ee5\u770b\u5230\u4e86<\/p>\n<p>\u7528conda activate \u6fc0\u6d3b\u4f7f\u7528\u5373\u53ef<\/p>\n<p>&nbsp;<\/p>\n<p>PS\uff1a\u4ee5\u4e0a\u4e09\u79cd\u65b9\u5f0f\uff0c\u5747\u4e0d\u652f\u6301WINDOWS\uff0cLINUX\/UNIX\uff0c\u7b49\u8fd9\u6837\u8de8\u7cfb\u7edf\u7684\u8fc1\u79fb\uff0c\u4e5f\u4e0d\u652f\u6301arm X86\u8de8\u82af\u7247\u7ec4\u7684\u8fc1\u79fb\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4e0d\u540c\u7cfb\u7edf\u548c\u4e0d\u540c\u67b6\u6784\u6240\u5b89\u88c5\u7684\u7b2c\u4e09\u65b9\u5e93\u652f\u6301\u5305\u662f\u4e0d\u4e00\u6837\u7684\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u8fd9\u6837\u8de8\u7cfb\u7edf\u8fc1\u79fb\uff0c\u8bf7\u8001\u8001\u5b9e\u5b9e\u591a\u4e0b\u8f7d\u4e00\u4e9bwhl\u6587\u4ef6\uff0c\u624b\u52a8\u5b89\u88c5\u6216\u8005\u5199\u811a\u672c\u6279\u91cf\u5b89\u88c5<\/p>\n<p>\u6216\u8005\u5c31\u662f\u8001\u8001\u5b9e\u5b9e\u5199requirements\u7528\u7f51\u7edc\u5b89\u88c5\u7684\u65b9\u5f0f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5df1\u7684\u5f00\u53d1\u7535\u8111\u53ef\u4ee5\u4f7f\u7528\u7f51\u7edc\uff0c\u751f\u4ea7\u7535\u8111\u4e0d\u80fd\u8054\u7f51\uff0c\u53ef\u80fd\u5c31\u9700\u8981\u7528\u5230\u79bb\u7ebf\u73af\u5883\u8fc1\u79fb\u8fd9\u4e2a\u529f\u80fd\u4e86\uff0cPython\u8bed\u8a00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86,30],"tags":[63,87,31],"class_list":["post-1021","post","type-post","status-publish","format-standard","hentry","category-macos","category-python","tag-conda","tag-macos","tag-python"],"views":8002,"_links":{"self":[{"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/posts\/1021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1021"}],"version-history":[{"count":5,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/posts\/1021\/revisions"}],"predecessor-version":[{"id":1026,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/posts\/1021\/revisions\/1026"}],"wp:attachment":[{"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mustenaka.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}