{"id":1050,"date":"2017-09-23T00:12:34","date_gmt":"2017-09-22T16:12:34","guid":{"rendered":"http:\/\/blog.xiunian.wang\/?p=1050"},"modified":"2017-11-17T14:48:16","modified_gmt":"2017-11-17T06:48:16","slug":"%e6%89%8b%e6%8a%8a%e6%89%8bmac%e5%ae%89%e8%a3%85%e5%a4%9a%e4%b8%aa%e7%89%88%e6%9c%acpython%ef%bc%8c%e5%b9%b6%e9%bb%98%e8%ae%a4%e6%8c%87%e5%ae%9apython3","status":"publish","type":"post","link":"https:\/\/blog.xiunian.wang\/?p=1050","title":{"rendered":"Mac\u5b89\u88c5\u591a\u4e2a\u7248\u672cpython\uff0c\u5e76\u9ed8\u8ba4\u6307\u5b9apython3"},"content":{"rendered":"<h4>1.\u5b89\u88c5pyenv<\/h4>\n<p>brew install pyenv<\/p>\n<h4>2.\u5b89\u88c53.6.2 python<\/h4>\n<p>pyenv install 3.6.2 -v<\/p>\n<p>\u5982\u679c\u9047\u5230\u8bf8\u5982\u4ee5\u4e0b\u9519\u8bef\u5219\u7ee7\u7eed\u4e0b\u770b\uff0c\u5982\u679c\u6ca1\u6709\u5219\u76f4\u63a5\u770b\u4e0b\u4e00\u6b65\u3002<\/p>\n<pre><code>pyenv zipimport.ZipImportError: can't decompress data; zlib not available\n<\/code><\/pre>\n<p>\u5728\u7ec8\u7aef\u8fd0\u884c xcode-select &#8211;install<br \/>\n\u5b89\u88c5xcode\u7684\u63d2\u4ef6<br \/>\n<!--more--><br \/>\n\u5982\u679c\u662fubuntu \u6216\u8005\u5176\u4ed6\u7cfb\u7edf\u53ef\u4ee5\u5b89\u88c5\u5982\u4e0b\u4ee3\u7801<\/p>\n<pre><code>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \\\nlibreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \\\nxz-utils tk-dev\n<\/code><\/pre>\n<h4>3.\u8bbe\u7f6epyenv<\/h4>\n<pre><code class=\"shell\">Usage: pyenv &lt;command&gt; [&lt;args&gt;]\n\nSome useful pyenv commands are:\n   commands    \u5217\u51fa\u6240\u6709pyenv\u53ef\u7528\u7684\u547d\u4ee4\n   local       \u8bbe\u7f6e\u6216\u663e\u793a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u7279\u5b9a\u7684Python\u7248\u672c\n   global      \u8bbe\u7f6e\u6216\u663e\u793a\u7cfb\u7edf\u5168\u5c40\u7684Python\u7248\u672c\n   shell       \u8bbe\u7f6e\u6216\u663e\u793ashell\u5916\u58f3\u7684Python\u7248\u672c\n   install     \u4f7f\u7528python-build\u5b89\u88c5\u6307\u5b9aPython\u7248\u672c\n   uninstall   \u5378\u8f7d\u5df2\u7ecf\u5b89\u88c5\u7684Python\n   rehash      \u5237\u65b0 pyenv shims (\u5b89\u88c5\u4e4b\u540e\u8fd0\u884c\u8fd9\u4e2a)\n   version     \u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684\u7248\u672c\n   versions    \u5217\u51fa\u5df2\u7ecf\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u5f53\u524d\u6fc0\u6d3b\u7248\u672c\u7528*\u53f7\u6807\u6ce8\n   which       \u663e\u793a\u7684\u5b8c\u6574\u8def\u5f84\u7684\u53ef\u6267\u884c\u6587\u4ef6\n   whence      \u5217\u51fa\u5305\u542b\u7ed9\u5b9a\u7684\u53ef\u6267\u884c\u6240\u6709\u7684Python\u7248\u672c\n\n<\/code><\/pre>\n<p>\u4ee5\u4e3a\u8fd9\u6837\u5c31\u641e\u5b9a\u4e86\u3002\u3002\u3002\u53ef\u662f\uff1a<\/p>\n<p>\u5f53\u6211\u5728shell\u4e2d\u8f93\u5165<\/p>\n<p>pyenv local 3.6.2 #\u8bbe\u7f6e\u673a\u5b50\u4f7f\u7528\u7684python\u4e3a3.4.2\u7248\u672c<br \/>\n$python &#8211;version<br \/>\n$2.7.8<\/p>\n<p>\u53d1\u73b0python\u8fd8\u662f\u4e4b\u524d\u7684\u7248\u672c\uff0c\u8fd9\u53c8\u662f\u54ea\u91cc\u51fa\u95ee\u9898\uff1f<br \/>\n\u7ecf\u8fc7\u67e5\u9605\uff0c\u5728bash\u4e2d\u8bbe\u7f6e\u6700\u540e\u4e00\u884c\u52a0\u4e0a\u5982\u4e0b\u8bed\u53e5<br \/>\nvi ~\/.bash_profile<\/p>\n<pre><code>if which pyenv &gt; \/dev\/null; then eval \"$(pyenv init -)\"; fi\n<\/code><\/pre>\n<p>\u6267\u884c source ~\/.bash_profile<br \/>\n\u91cd\u542f \u5c31\u80fd\u770b\u5230\u6548\u679c\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5b89\u88c5pyenv brew install pyenv 2.\u5b89\u88c53.6.2 python pyenv install 3.6.2 -v \u5982\u679c\u9047\u5230\u8bf8\u5982\u4ee5\u4e0b\u9519\u8bef\u5219\u7ee7\u7eed\u4e0b\u770b\uff0c\u5982\u679c\u6ca1\u6709\u5219\u76f4\u63a5\u770b\u4e0b\u4e00\u6b65\u3002 pyenv zipimport.ZipImportError: can&#8217;t decompress data; zlib not available \u5728\u7ec8\u7aef\u8fd0\u884c xcode-select &#8211;install \u5b89\u88c5xcode\u7684\u63d2\u4ef6<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts\/1050"}],"collection":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1050"}],"version-history":[{"count":7,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts\/1050\/revisions"}],"predecessor-version":[{"id":1098,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts\/1050\/revisions\/1098"}],"wp:attachment":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}