1

I want to create a script to setup an environment on a Mac. Here's a simple sample...

#!/bin/bash
brew install gcovr || exit 1
gcovr --version

NOTE: Script assumes brew was previously installed .

When I execute the script I get an error.

$ ./install
Warning: gcovr 4.1 is already installed and up-to-date
To reinstall 4.1, run `brew reinstall gcovr`
Traceback (most recent call last):
  File "/usr/local/Cellar/gcovr/4.1/libexec/bin/gcovr", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

However, if I run it directly from the command line, it progresses as expected.

$ brew install gcovr
Warning: gcovr 4.1 is already installed and up-to-date
To reinstall 4.1, run `brew reinstall gcovr`

It should be noted, the script does install gcovr before failing and bailing.

2

It appears this error comes from Python being misconfigured.

The answer is to brew postinstall python3.

When Googling around, I found a separate project demonstrating a similar issue.

Here is what I saw on my machine:

$ python --version
Python 2.7.10
$ brew install python
Warning: python 3.7.4 is already installed, it's just not linked
You can use `brew link python` to link this version.
$ brew postinstall python3
==> Postinstalling python
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install

After running postinstall, it didn't appear to change Python

$ python --version
Python 2.7.10

However, it did postively affect Homebrew, and allowed the script to run successfully!

$ ./install
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

Warning: gcovr 4.1 is already installed and up-to-date
To reinstall 4.1, run `brew reinstall gcovr`
gcovr 4.1

Copyright 2013-2018 the gcovr authors
Copyright 2013 Sandia Corporation
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .