When I run pytest I get an error called ImportError: cannot import name 'ft2font'
In detail, I get the following.
During handling of the above exception, another exception occurred:
../../.local/lib/python3.6/site-packages/_pytest/config.py:376: in _importconftest
mod = conftestpath.pyimport()
../../.local/lib/python3.6/site-packages/py/_path/local.py:701: in pyimport
__import__(modname)
lib/matplotlib/__init__.py:174: in <module>
_check_versions()
lib/matplotlib/__init__.py:159: in _check_versions
from . import ft2font
E ImportError: cannot import name 'ft2font'
Is this something to do with my Python or Matplotlib installation?
On macOS10.13, I’m trying to build matplotlib-2.2.5 with python37 (using Fink installed libraries and python37; no pip, no anaconda). There’s no previous version of matplotlib installed, and the python3.7 at /sw/bin/python3.7 is the only python37 available (there’s /usr/bin/python, which is 2.7). matplotlib is not yet installed at this point because the tests are run after building but before installation. This methodology works with dozens of other pythonmods that use our pytest module.
/sw/bin/py.test-3.7 || exit 2
=============================================================== test session starts ================================================================
platform darwin -- Python 3.7.8, pytest-5.1.2, py-1.8.0, pluggy-0.13.0
rootdir: /sw/build.build/matplotlib-py37-2.2.5-1/matplotlib-2.2.5, inifile: pytest.ini, testpaths: lib
collected 0 items / 1 errors
====================================================================== ERRORS ======================================================================
__________________________________________________________ ERROR collecting test session ___________________________________________________________
/sw/lib/python3.7/site-packages/_pytest/config/__init__.py:440: in _importconftest
return self._conftestpath2mod[conftestpath]
E KeyError: local('/sw/build.build/matplotlib-py37-2.2.5-1/matplotlib-2.2.5/lib/matplotlib/testing/conftest.py')
During handling of the above exception, another exception occurred:
/sw/lib/python3.7/site-packages/py/_path/common.py:377: in visit
for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
/sw/lib/python3.7/site-packages/py/_path/common.py:429: in gen
for p in self.gen(subdir):
/sw/lib/python3.7/site-packages/py/_path/common.py:418: in gen
dirs = self.optsort([p for p in entries
/sw/lib/python3.7/site-packages/py/_path/common.py:419: in <listcomp>
if p.check(dir=1) and (rec is None or rec(p))])
/sw/lib/python3.7/site-packages/_pytest/main.py:606: in _recurse
ihook = self.gethookproxy(dirpath)
/sw/lib/python3.7/site-packages/_pytest/main.py:424: in gethookproxy
my_conftestmodules = pm._getconftestmodules(fspath)
/sw/lib/python3.7/site-packages/_pytest/config/__init__.py:420: in _getconftestmodules
mod = self._importconftest(conftestpath)
/sw/lib/python3.7/site-packages/_pytest/config/__init__.py:465: in _importconftest
self.consider_conftest(mod)
/sw/lib/python3.7/site-packages/_pytest/config/__init__.py:518: in consider_conftest
self.register(conftestmodule, name=conftestmodule.__file__)
/sw/lib/python3.7/site-packages/_pytest/config/__init__.py:324: in register
ret = super().register(plugin, name)
/sw/lib/python3.7/site-packages/pluggy/manager.py:126: in register
hook._maybe_apply_history(hookimpl)
/sw/lib/python3.7/site-packages/pluggy/hooks.py:333: in _maybe_apply_history
res = self._hookexec(self, [method], kwargs)
/sw/lib/python3.7/site-packages/pluggy/manager.py:92: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
/sw/lib/python3.7/site-packages/pluggy/manager.py:86: in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
lib/matplotlib/testing/conftest.py:12: in pytest_configure
matplotlib._init_tests()
lib/matplotlib/__init__.py:1488: in _init_tests
from matplotlib import ft2font
E ImportError: cannot import name 'ft2font' from 'matplotlib' (/sw/build.build/matplotlib-py37-2.2.5-1/matplotlib-2.2.5/lib/matplotlib/__init__.py)