Setting Up Your Environment on macOS: Python 3.11, Ansible, and Visual Studio Code

When working on macOS, it’s essential to configure your PATH variable correctly to ensure smooth development workflows. Here’s a guide to set up the PATH for Python 3.11, Ansible, and Visual Studio Code.

Step 1: Setting the PATH for Python 3.11

To ensure that your terminal uses Python 3.11 by default, you need to update your PATH variable. Follow these steps:

  • Open the Terminal.
  • Edit your .bash_profile or .zshrc file (depending on your shell). You can use nano or vim:
$ vi ~/.bash_profile
  • Add the following lines to the file:
# Setting PATH for Python 3.11
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
export PATH

Step 2: Setting the PATH for Ansible

Next, you’ll want to set the PATH to include the directory where Ansible is installed:

# Setting PATH for Ansible
PATH="/Users/robermb/Library/Python/3.11/bin:${PATH}"
export PATH

Note: Replace “robermb” with your username.

Step 3: Adding Visual Studio Code to PATH

To open Visual Studio Code from the terminal using the code command, you need to add its binary to your PATH:

# Add Visual Studio Code (code)
PATH="/Users/robermb/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${PATH}"
export PATH
  • Save the file and exit the editor.
  • Reload your profile:
$ source ~/.bash_profile

Final Check

After updating and reloading your profile, you can check if the PATH is set correctly by running:

$ echo $PATH

You should see the paths you added listed at the beginning of the output.

Compartir:

This article was written by RoberMB

💻OS, ☁️Cloud, 🛡️Cybersecurity, ✈️Traveling #Linux, #Ansible, #AWS, #VMware, #Docker 🏴‍☠️ CEH v10, CPHE 🏴‍☠️ ... Always learning, always enjoying.

Leave a Reply

Your email address will not be published. Required fields are marked *