# MacOS

To follow this guide, you will need to install [Homebrew](https://brew.sh/) first.

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

After Homebrew is installed, let's install pyenv:

```bash
brew update
brew install pyenv
```

This command will show a list of Python versions:

```
pyenv install --list
```

Now let's install the latest Python version (3.8.5 as of this writing):

```
pyenv install 3.8.5
```

Now that Python 3 is installed through pyenv, we want to set it as our global default version for pyenv environments:

```
$ pyenv global 3.8.5
# and verify it worked
$ pyenv version
```

The power of pyenv comes from its control over our shell's path.\
In order for it to work correctly, we need to add the following to our configuration file (**.zshrc** or **.bash\_profile**) depending on your terminal version:

```
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc
```

```
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
```

Now create a new terminal session and run:

```
python -V
```

You should see the 3.8.5 version showing up.

Sources:

* <https://brew.sh/>
* <https://github.com/pyenv/pyenv>
* <https://opensource.com/article/19/5/python-3-default-mac>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.productizeml.com/productize-ml/hands-on/python-ml/python-installation/python_macos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
