{"id":7792,"date":"2019-01-07T16:38:20","date_gmt":"2019-01-07T08:38:20","guid":{"rendered":"http:\/\/rmohan.com\/?p=7792"},"modified":"2019-01-07T16:38:21","modified_gmt":"2019-01-07T08:38:21","slug":"pyenv-pyenv-virtualenv-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7792","title":{"rendered":"pyenv + pyenv-virtualenv (CentOS 7)"},"content":{"rendered":"\n<p>Overview<br>\nI summarized the installation on CentOS. <br>\nAlthough it is little different from OSX, it is organized because the premise environment is different.<\/p>\n\n\n\n<p>environment<br>\nI am trying in the next environment.<\/p>\n\n\n\n<p>$ uname -r<br>\n3.10.0-229.14.1.el7.x86_64<br>\n$ lsb_release -a<br>\nLSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch<br>\nDistributor ID: CentOS<br>\nDescription:    CentOS Linux release 7.1.1503 (Core) <br>\nRelease:    7.1.1503<br>\nCodename:   Core<\/p>\n\n\n\n<p>Installing packages<\/p>\n\n\n\n<p>Installation of packages required for CentOS<\/p>\n\n\n\n<p>yum -y install git<br>\nyum -y groupinstall &#8220;Development Tools&#8221;<br>\nyum -y install readline-devel zlib-devel bzip2-devel sqlite-devel openssl-devel<\/p>\n\n\n\n<p>Installation of pyenv<\/p>\n\n\n\n<p>git clone https:\/\/github.com\/yyuu\/pyenv.git ~\/.pyenv<br>\necho &#8216;export PYENV_ROOT=&#8221;$HOME\/.pyenv&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br>\necho &#8216;export PATH=&#8221;$PYENV_ROOT\/bin:$PATH&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br>\necho &#8216;eval &#8220;$(pyenv init -)&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br>\nsource ~\/.bash_profile<br>\nexec $SHELL -l<\/p>\n\n\n\n<p>pyenv-virtualenv <\/p>\n\n\n\n<p>git clone https:\/\/github.com\/yyuu\/pyenv-virtualenv.git ~\/.pyenv\/plugins\/pyenv-virtualenv<br>\necho &#8216;eval &#8220;$(pyenv virtualenv-init -)&#8221;&#8216; &gt;&gt; ~\/.bash_profile<br>\nexec $SHELL -l<\/p>\n\n\n\n<p>How to use pyenv<\/p>\n\n\n\n<p>List of installable distributions, versions<\/p>\n\n\n\n<p>pyenv install 2.7.10<br>\npyenv install 3.5.0<\/p>\n\n\n\n<p>Installation<\/p>\n\n\n\n<p>Installation of the version you want to use<\/p>\n\n\n\n<p>$ pyenv versions<\/p>\n\n\n\n<ul><li>system (set by \/home\/saitou\/.pyenv\/version)<br>\n2.7.10<br>\n3.5.0<\/li><\/ul>\n\n\n\n<p>Changing the version to be used by default<\/p>\n\n\n\n<p>Do not make changes to Python on the system side. <br>\nIn the following, 2.7.10 which was additionally installed is changed to the default of the user environment.<\/p>\n\n\n\n<p>pyenv global 2.7.10<br>\npip install &#8211; U pip<br>\nIf you want to use Python on the system side, specify system.<\/p>\n\n\n\n<p>$ python -V<br>\nPython 2.7.5<br>\n$ pyenv global 2.7.10<br>\n$ python -V<br>\nPython 2.7.10<br>\n$ pyenv global system<br>\n$ python -V<br>\nPython 2.7.5<\/p>\n\n\n\n<p>How to use pyenv + pyenv-virtualenv<\/p>\n\n\n\n<p>pyenv virtualenv  <\/p>\n\n\n\n<p>I want to use different versions for each project. <br>\nIn this way you can allocate specific directories to specific versions and use them separately.<\/p>\n\n\n\n<p>$ pyenv virtualenv 3.5.0 new_env<br>\n$ mkdir -p work\/new_project &amp;&amp; work\/new_project\/<br>\n$ pyenv versions<\/p>\n\n\n\n<ul><li>system (set by \/home\/saitou\/.pyenv\/version)<br>\n2.7.10<br>\n3.5.0<br>\nnew_env<br>\n$ pyenv local new_env<br>\npyenv-virtualenv: activate new_env<br>\n$ python -V<br>\nPython 3.5.0<br>\n$ cd ..<br>\npyenv-virtualenv: deactivate new_env<br>\n$ python -V<br>\nPython 2.7.5<br>\n$ cd new_project\/<br>\npyenv-virtualenv: activate new_env<br>\n$ python -V<br>\nPython 3.5.0<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"\n<p>Overview I summarized the installation on CentOS. Although it is little different from OSX, it is organized because the premise environment is different.<\/p>\n<p>environment I am trying in the next environment.<\/p>\n<p>$ uname -r 3.10.0-229.14.1.el7.x86_64 $ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.1.1503 (Core) Release: 7.1.1503 Codename: Core<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7792"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7792"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7792\/revisions"}],"predecessor-version":[{"id":7793,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7792\/revisions\/7793"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}