{"id":4,"date":"2014-02-14T04:48:56","date_gmt":"2014-02-13T20:48:56","guid":{"rendered":"http:\/\/vinta.ws\/code\/?p=4"},"modified":"2026-02-18T01:20:37","modified_gmt":"2026-02-17T17:20:37","slug":"pyenv-python-version-management","status":"publish","type":"post","link":"https:\/\/vinta.ws\/code\/pyenv-python-version-management.html","title":{"rendered":"pyenv: Python Version Manager"},"content":{"rendered":"<p>A simple Python version manager. It is recommended to use <code>pyenv<\/code> and <code>pipenv<\/code> together.<\/p>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/yyuu\/pyenv\">https:\/\/github.com\/yyuu\/pyenv<\/a><\/p>\n<h2>Install<\/h2>\n<p>Before doing the following steps, you must install Command Line Tools.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ brew update\n$ brew install readline openssl\n\n$ brew install pyenv\n# or\n$ brew upgrade pyenv\nTo enable shims and autocompletion add to your profile:\n  if which pyenv &gt; \/dev\/null; then eval \"$(pyenv init -)\"; fi\n\n$ pyenv --version\npyenv 1.2.14<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/vinta\/HAL-9000\/blob\/master\/playbooks\/roles\/python\/files\/pyenv_profile.sh\">https:\/\/github.com\/vinta\/HAL-9000\/blob\/master\/playbooks\/roles\/python\/files\/pyenv_profile.sh<\/a><\/p>\n<h2>Usage<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-bash\"># list available Python versions\n$ pyenv install -l\n\n# install a certain version\n$ pyenv install 2.7.16\n$ pyenv install 3.7.4\n\n# list installed Python versions\n$ pyenv versions\n\n# set the default Python version\n$ pyenv global 3.5.1\n\n# you can set both Python 2 and 3\n$ pyenv global 3.7.4 2.7.16\n\n# switch to the system default Python version\n$ pyenv global system\n\n# set the Python version for the current folder\n# which generates <code>.python-version<\/code> in the same folder\n$ pyenv local 3.7.4\n\n# set the Python version for the current shell\n$ pyenv shell 3.7.4<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/pyenv\/pyenv\/blob\/master\/COMMANDS.md\">https:\/\/github.com\/pyenv\/pyenv\/blob\/master\/COMMANDS.md<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A simple Python version management. It is recommended to use pyenv and pipenv together.<\/p>\n","protected":false},"author":1,"featured_media":757,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[51,2],"class_list":["post-4","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-about-python","tag-env","tag-python"],"_links":{"self":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/4","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":0,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media\/757"}],"wp:attachment":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}