Error on the "Install the Ansible Galaxy roles" step of Trellis installation (Newbie)

Hi,

I tried to make my first installation of Trellis, Bedrock and Sage following the docs and i have a problem during the Trellis installation during step 4 (“Install the Ansible Galaxy roles”).

The result to the command:
$ ansible-galaxy install -r requirements.yml

is this error message:

ERROR! Unexpected Exception: ‘ImportError’ object has no attribute 'message’
the full traceback was:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible-galaxy”, line 73, in
mycli = getattr(import(“ansible.cli.%s” % sub, fromlist=[myclass]), myclass)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ansible/cli/galaxy.py”, line 37, in
from ansible.galaxy.api import GalaxyAPI
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ansible/galaxy/api.py”, line 30, in
from urllib2 import quote as urlquote, HTTPError
ImportError: No module named ‘urllib2’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible-galaxy”, line 79, in
if e.message.endswith(’ %s’ % sub):
AttributeError: ‘ImportError’ object has no attribute ‘message’

I have installed ansible 2.0.2.0 and i’m using Os X 10.11.3.

Thanks for your help!

1 Like

Ansible only works with Python 2 and from your traceback it looks like 3.5 is being used? Maybe it’s the default on OS X 10.11 now. My guess is that you need to install Python 2.x.

1 Like

I got a similar error on OX El Capitain:

ERROR! Unexpected Exception: (setuptools 1.1.6 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse(‘setuptools>=11.3’))
the full traceback was:

Traceback (most recent call last):
_ File “/usr/local/bin/ansible-galaxy”, line 73, in _
_ mycli = getattr(import(“ansible.cli.%s” % sub, fromlist=[myclass]), myclass)_
_ File “/Library/Python/2.7/site-packages/ansible/cli/galaxy.py”, line 38, in _
_ from ansible.galaxy.role import GalaxyRole_
_ File “/Library/Python/2.7/site-packages/ansible/galaxy/role.py”, line 35, in _
_ from ansible.playbook.role.requirement import RoleRequirement_
_ File “/Library/Python/2.7/site-packages/ansible/playbook/init.py”, line 25, in _
_ from ansible.playbook.play import Play_
_ File “/Library/Python/2.7/site-packages/ansible/playbook/play.py”, line 27, in _
_ from ansible.playbook.base import Base_
_ File “/Library/Python/2.7/site-packages/ansible/playbook/base.py”, line 35, in _
_ from ansible.parsing.dataloader import DataLoader_
_ File “/Library/Python/2.7/site-packages/ansible/parsing/dataloader.py”, line 32, in _
_ from ansible.parsing.vault import VaultLib_
_ File “/Library/Python/2.7/site-packages/ansible/parsing/vault/init.py”, line 67, in _
_ from cryptography.hazmat.primitives.hashes import SHA256 as c_SHA256_
_ File “/Library/Python/2.7/site-packages/cryptography/hazmat/primitives/hashes.py”, line 15, in _
_ from cryptography.hazmat.backends.interfaces import HashBackend_
_ File “/Library/Python/2.7/site-packages/cryptography/hazmat/backends/init.py”, line 7, in _
_ import pkg_resources_
_ File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py”, line 2797, in _
_ parse_requirements(requires), Environment()_
_ File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py”, line 580, in resolve_
_ raise VersionConflict(dist,req) # XXX put more info here_
VersionConflict: (setuptools 1.1.6 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse(‘setuptools>=11.3’))

Hi. in my case I have Python 2.x running, but I got the error that I put bellow, any thoughts?

Sorry, but I’m not really sure. This is more of a Python issue on your local machine than an Ansible or Trellis issue. You could try re-installing Python through Homebrew.

As long as you have python (not python3) installed via homebrew,I would venture a guess that either

  1. Homebrew is not at the “top” of your PATH environment variable. Fix this within ~/.profile or ~/.bash_profile with the line like: export PATH=/usr/local/bin:/usr/local/sbin:$PATH, or
  2. pip setuptools may be an old version, which can be remedied (and everything else listed & updated) with:
    $ pip list --outdated
    $ pip install --upgrade pip setuptools
    $ pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
4 Likes

I didn’t install any Python version, Python is default in my machine:

~ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin

Well then…get homebrew fully setup and install (at least) python & ansible installed with brew install. Then tell us what happens.

Stay away from sudo installs/updates into your system if you can help it. Leave that to Apple.

1 Like

It’s now fixed but in a wird way. After a long digg, i finally managed to upgrade the python setuptools with this:

pip install --upgrade setuptools --user python
(http://stackoverflow.com/questions/33234665/upgrading-setuptools-on-osx-el-capitan)

the wird stuff is that I got the same setuptools version (1.1.6) but now everything works fine with the Ansible Galaxy roles…

thanks for you support!

6 Likes

Thanks everybody for your answers!

I’ll try a few things based on your feedback and get back to you if i solve it… or not :wink:

Yes, that fixed it for me. Thanks!

Congratulations, that’s great news!

I would like to strongly suggest to you (and anyone else reading this thread) to get homebrew onto any Macintosh you plan on using Trellis with.

Updating OS X system components is a no win, zero sum game. At best, if you are lucky, you will likely need to run these upgrade commands again when a new OS update comes out. At worst, you break system functionality and sometimes are almost forced to do global/sudo installs of ansible, npm, etc.

A few years ago, I did not use homebrew and had horrible experiences with OS X updates overwriting multiple ruby packages. I would never wish a forced OS X re-install to anyone working on deadlines

1 Like

Hi,

based on your feedback, after a long struggle, Google searching, reading online tutoriels and fiddling in the Terminal, i managed somehow to pass successfully that step 4 of the Trellis install!

i resolved my problem by:

  • uninstalling Python 3.5 (and Ansible which i had previously installed in it), leaving only the Python version of El Capitan
  • installing pyenv via homebrew
  • installing Python 2.7.11 and 3.5.1 via pyenv
  • setting Python 2.7.11 as global via pyenv
  • re-installing Ansible via pip in the Python 2.7.11 managed by pyenv

Once everything correctly installed, it just worked (and i learned a few tricks, still a newbie though).

Next step: configuring the WordPress sites, wish me luck :wink:

4 Likes

I ran into a similar issue on vagrant up, after I upgraded pip. I upgraded setuptools but was unable to upgrade asnisble. Wrote the ansible upgrade command like this and it worked fine.
sudo -H pip install --upgrade ansible --user python

It was working for me… until I install Homebrew… Now I’m stuck with this same issue, not sure how to proceed.

Do you know if the python/pip that you now have is via homebrew? You might want to start with which pip to make sure it is within a homebrew directory (/usr/local/bin/) and then follow the 3 pip list/install/freeze commands from my April 30 post. Separately, you can update all of homebrew with these three commands: brew update; brew upgrade --all; brew doctor

1 Like

Yes it’s good!

Everything is up to date.

The freeze command brings an error message :slight_smile:

Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run prefix=options.prefix_path, File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in install requirement.uninstall(auto_confirm=True) File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 742, in uninstall paths_to_remove.remove(auto_confirm) File "/usr/local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move rmtree(src) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree os.remove(fullname) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/ansible-2.0.2.0-py2.7.egg-info/dependency_links.txt'

Did you copy/paste the whole last line?
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U

That last OSError line is a concern as is referencing the OS (and not homebrew) system. I don’t even have a a thought as to a direction to point you in with that one. :confused:

Yes I did :wink:

I did a “doctor” and I have unlinked directories apparently, trying some fixes… Not sure where I’m going ^^°

Currently reading this : https://github.com/pypa/pip/issues/3636

So the Freeze is still bringing an error message BUT the ansible galaxy role has been installed and vagrant up is working now :slight_smile:

Maybe after a sudo pip upgrade?