I am using different programming languages like C#, Java, Node.js etc.
So, I definitely need to switch between runtime environments.
For example, there are some package managers in Node.js community like nvm or n. I am very happy to use both of two package managers 🙂
Let's say I work for one Node.js project in dev machine with Node v8.0.0 but other project needs Node v6.0.0
In order to handle, different versions in same machine, we may use package managers.
I just want to find a way to switch between different Python version so that found pyenv package manager.
There are also others like asdf,
rbenv package managers.
Click pyenv link for more detailed installation.
Installing pyenv with Homebrew
First, ensure that you have Homebrew installed in your system. Homebrew is a package manager for Mac OS. So if you want to learn more details about it, visit my blog below.
Run the following commands in your terminal. But, just copy commands without $ sign.
$ brew update
$ brew install pyenv
Run the following command for advanced configuration.
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
Run the following command for basic configuration.
$ echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.bash_profile
and restart your terminal manually or run the following command to restart automatically.
$ exec "$SHELL"
$ brew upgrade pyenv
$ rm -rf $(pyenv root)
$ brew uninstall pyenv
List all Python versions installed in system
$ pyenv versions
* 3.8.2 (set by /Users/kenanhancer/.pyenv/version)
Show current active Python version in system
$ pyenv version
3.8.2 (set by /Users/kenanhancer/.pyenv/version)