Trellis does not yet support Python 3.6.4

After I clone the trellis and bedrock repos to the relevant directory and run vagrant up, I receive this error.

ERROR! Trellis does not yet support Python 3.6.4.
Please use Python 2.7.

I’m on macOS High Sierra 10.13.6 and when I run python --version I get back 3.6.4.

Looking at other posts on this board, I notice that people recommend uninstalling python 3 in order to default back to python 2. I use python 3 for work and I would prefer not to uninstall it. Is there a way I can have the relevant trellis/ansible files use python 2 instead of my default python 3?


Try a python version manager:

I installed pyenv, then install python 2 with pyenv and then set the local python version to 2.7 but the installation still failed with the same exact message.

1 Like

I tried virtualenv too and it didn’t work.

virtualenv --python=/usr/bin/python2.7 trellisenv
source tresslisenv/bin/activate
vagrant up

Still gives my the python version error.

I got it working with Anaconda.

conda create --name trellisenv python=2.7
source activate trellisenv
conda install ansible=2.5.3
vagrant up

It successfully installs using this method, but when I go the address stipulated by canonical, the local server doesn’t load in my browser. Not sure what the issue is, but at least it apparently installed correctly.

I’ve successfully used virtualenv and virtualendwrapper. I already had Python 3 and 2.7 from homebrew.

pip install virtualenvwrapper
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/
mkvirtualenv -p /usr/bin/python2.7 p2
pip install ansible==
vagrant up

So whenever I want Python 2, I use that virtualenv. Otherwise I just use Python 3 without it.

Hi all,

I have seen you were working on making Trellis python3 compatible (branch trellis/python-3-compat).
What is the advancement of that? Would it be useable at beta stage?



bump @swalkinshaw ?

Thanks in advance!

For the record; and future readers: Trellis does support Python 3 since some months ago.
Topic can be closed.


For those who need to do something in an old trellis install (and don’t want to deal with updating it), on OS X, Python 2.7 can be installed via Homebrew with:

brew install

(NOTE: Scott suggests, here, that provisioning a new server as a good practice, when there have been significant (“breaking”) changes, such as upgrades to php.)

If source /usr/local/bin/ script is returning an error:

  pip <command> [options]

no such option: -m There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/pip and that PATH is
set properly.

Fix is to add the following line to /.bashrc (or .bash_profile), before setting the VIRTUALENVWRAPPER_PYTHON variable::

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python # for brew installed python

I’m not sure what the best way to figure out which version of Ansible you need for your version of Trellis is. If it’s too old, Trellis will tell you. I guess you can also look at trellis/plugins/vars/ and see what version_requirement is.

Adding a few more notes here.

  • create virtual environment that runs Python2:
    • $ which python2 (let’s say it returns /usr/local/bin/python2
    • /usr/local/bin/python2 -m virtualenv trellis (or maybe the dir above trellis)
    • Activate the env: source trellis/bin/activate

Now, maybe from checking trellis/lib/trellis/plugins/vars/, determine which version of Ansible you need to run, and install it with pip:

  • pip install ansible==2.4.3

It’s possibly you’ll also need to install the requirements again:

  • pip install -r /path/to/requirements.txt

And potentially the Galaxy dependencies as well.`

1 Like