{"action":"created","issue":{"url":"https://api.github.com/repos/yyuu/pyenv/issues/492","labels_url":"https://api.github.com/repos/yyuu/pyenv/issues/492/labels{/name}","comments_url":"https://api.github.com/repos/yyuu/pyenv/issues/492/comments","events_url":"https://api.github.com/repos/yyuu/pyenv/issues/492/events","html_url":"https://github.com/yyuu/pyenv/issues/492","id":119370490,"number":492,"title":"Is there a preferred way to use pyenv in a shell script?","user":{"login":"cjerdonek","id":355822,"avatar_url":"https://avatars.githubusercontent.com/u/355822?v=3","gravatar_id":"","url":"https://api.github.com/users/cjerdonek","html_url":"https://github.com/cjerdonek","followers_url":"https://api.github.com/users/cjerdonek/followers","following_url":"https://api.github.com/users/cjerdonek/following{/other_user}","gists_url":"https://api.github.com/users/cjerdonek/gists{/gist_id}","starred_url":"https://api.github.com/users/cjerdonek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjerdonek/subscriptions","organizations_url":"https://api.github.com/users/cjerdonek/orgs","repos_url":"https://api.github.com/users/cjerdonek/repos","events_url":"https://api.github.com/users/cjerdonek/events{/privacy}","received_events_url":"https://api.github.com/users/cjerdonek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yyuu/pyenv/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-11-29T17:00:19Z","updated_at":"2015-11-30T01:48:03Z","closed_at":"2015-11-29T21:05:51Z","body":"The `PYENV_VERSION` environment variable doesn't seem to work as documented.  The documentation says in the README:\r\n\r\n> When you execute a shim, pyenv determines which Python version to use by reading it from the following sources, in this order:\r\n>\r\n> 1. The `PYENV_VERSION` environment variable (if specified). You can use the `pyenv shell` command to set this environment variable in your current shell session.\r\n> 2. ...\r\n\r\nHowever, if I manually set `PYENV_VERSION`, the version doesn't change.  So it seems like there's something more than simply this environment variable:\r\n\r\n```\r\n$ pyenv versions\r\n* system (set by /Users/chris/.pyenv/version)\r\n  2.7.10\r\n  3.4.3\r\n  3.5.0\r\n$ PYENV_VERSION=3.5.0\r\n$ echo $PYENV_VERSION\r\n3.5.0\r\n$ pyenv versions\r\n* system (set by /Users/chris/.pyenv/version)\r\n  2.7.10\r\n  3.4.3\r\n  3.5.0\r\n$ pyenv shell 3.5.0\r\n$ echo $PYENV_VERSION\r\n3.5.0\r\n$ pyenv versions\r\n  system\r\n  2.7.10\r\n  3.4.3\r\n* 3.5.0 (set by PYENV_VERSION environment variable)\r\n```\r\n\r\nThe reason I'm interested in this approach is that I'm trying to use `pyenv` in a shell script to temporarily change Python versions, and using `pyenv shell` in the shell script gives me the following error:\r\n\r\n> pyenv: no such command `shell'\r\n\r\nIf you know a better / preferred way to change the current version in a shell script, it would be appreciated.  Thanks.\r\n"},"comment":{"url":"https://api.github.com/repos/yyuu/pyenv/issues/comments/160496299","html_url":"https://github.com/yyuu/pyenv/issues/492#issuecomment-160496299","issue_url":"https://api.github.com/repos/yyuu/pyenv/issues/492","id":160496299,"user":{"login":"cjerdonek","id":355822,"avatar_url":"https://avatars.githubusercontent.com/u/355822?v=3","gravatar_id":"","url":"https://api.github.com/users/cjerdonek","html_url":"https://github.com/cjerdonek","followers_url":"https://api.github.com/users/cjerdonek/followers","following_url":"https://api.github.com/users/cjerdonek/following{/other_user}","gists_url":"https://api.github.com/users/cjerdonek/gists{/gist_id}","starred_url":"https://api.github.com/users/cjerdonek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjerdonek/subscriptions","organizations_url":"https://api.github.com/users/cjerdonek/orgs","repos_url":"https://api.github.com/users/cjerdonek/repos","events_url":"https://api.github.com/users/cjerdonek/events{/privacy}","received_events_url":"https://api.github.com/users/cjerdonek/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T01:48:03Z","updated_at":"2015-11-30T01:48:03Z","body":"@yyuu Sorry, the case I had in mind is if there is additional code later on in the shell script."}}