Setting up Python venv for Ansible
In this quick tutorial we'll set up python on a mac os x in order to run ansble from the current folder.
Python on a mac is already installed. However, it's version 2 and we want version 3. We'll install a newer python with `brew`. You have to have `brew` installed:
brew --version
## install brew if you haven't already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Then, you can install python3 like so:
brew install python
which python3
python3 -m pip install --user --upgrade pip
python3 -m pip --versionFinally, create a venv in the current folder and activate it:
cd <whereever you need to be>
python3 -m venv zenv
## or:
python3 -m venv zenv_with_a_more_specific_name
## then:
. zenv/bin/activateGiven all this, your shell will be running a local version of python with local versions of all the packages. Enjoy! To quit the venv, type the following command:
deactivate.^.
Related Articles
Please log in to post comments:
Login with Google