fontbakery: ModuleNotFoundError: No module named 'fontforge'

Observed behaviour

When I try to install FontBakery, I get the following error:

Collecting fontbakery (from -r requirements.txt (line 8))
  Using cached https://files.pythonhosted.org/packages/a6/19/07b7166d7ff8f95a7beb41ae533a23c283a539f771b0baad0f9983adea04/fontbakery-0.0.13.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-gt4owhmn/fontbakery/setup.py", line 25, in <module>
        import fontforge
    ModuleNotFoundError: No module named 'fontforge'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-gt4owhmn/fontbakery/setup.py", line 27, in <module>
        raise Exception(msg)
    Exception: Python module `fontforge` is required. Install it with `apt-get install python-fontforge` or `brew install python; brew install fontforge --HEAD`
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-gt4owhmn/fontbakery/

So, I ran:

▶ brew install python; brew install fontforge --HEAD
Warning: python 3.7.3 is already installed and up-to-date
To reinstall 3.7.3, run `brew reinstall python`
Warning: fontforge  is already installed
The currently linked version is 20190413
You can use `brew switch fontforge ` to link this version.

Then

▶ brew switch fontforge 20190413
Cleaning /usr/local/Cellar/fontforge/20190413
55 links created for /usr/local/Cellar/fontforge/20190413

But I ended up with the same error as before.

Expected behaviour

I expect FontBakery to install without this error, because I have already install fontforge, as homebrew confirms.

Resources and exact process needed to replicate

Encode Sans at https://github.com/thundernixon/Encode-Sans/tree/4c0afcc9e79bd91238ebb4a834516b93fa128d7b

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

https://stackoverflow.com/a/17153977 :

You can get pip to give verbose output using the -v flag … but one isn’t enough. I RTFM-ed the help, which said you can do -v multiple times, up to 3x, for more verbose output.

This is, hands down, one of the stupidest things I’ve ever read.

I think that this may be due to the fact that the Python fontforge module is coming from a brew install of fontforge command line tools (not from pip3 where it doesn’t exist/is not distributed). Looking at the Homebrew Ruby formula for fontforge, it seems that the Python module that it installs is Py2 only. Your Py3 venv can’t import it. The old FB version doesn’t handle the fontforge import exception and chokes…

I think 😃

An important thing to remember is that fontbakery does not require fontforge anymore since the latest release from last week.

Hahaha, that is incredible.

But wait … that literally IS in the pip doc.

-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
(venv)
type-repos/google-font-repos/Encode-Sans  master ✗                                                                                                                                                                                                                                                                                                              4h25m ✖ ⚑
▶ pip --help

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output

pip install --ignore-installed -r requirements.txt might do it?

Here is where you can find (and clear) your pip cache if necessary: https://stackoverflow.com/a/31807659