Python on Mac - install pdpbox - Command errored out with exit status 1

Hi, I am a new user to Python and I am learning about PDP recently.
I tried the pip install pdpbox commend on my Jupyter notebook, and I got this very very very long error message (warning ahead). I would greatly appreciate all suggestions/help on how to solve this problem. Thank you!
I tried: relaunch Jupyter
I tried: the pip install -U pip setuptools command, yet that ended with another error message.

Thanks again!
The error code are as below:
Building wheels for collected packages: matplotlib
Building wheel for matplotlib (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /opt/anaconda3/bin/python -u -c β€˜import io, os, sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’; file=’"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’;f = getattr(tokenize, β€˜"’"β€˜open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"β€˜from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, β€˜"’"’\n’"’"’);f.close();exec(compile(code, file, β€˜"’"β€˜exec’"’"’))’ bdist_wheel -d /private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-wheel-89pb522e
cwd: /private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/
Complete output (505 lines):
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies

Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
matplotlib: yes [3.1.1]
python: yes [3.8.8 (default, Apr 13 2021, 12:59:45) [Clang 10.0.0 ]]
platform: yes [darwin]

OPTIONAL SUBPACKAGES
sample_data: yes [installing]
tests: no [skipping due to configuration]

OPTIONAL BACKEND EXTENSIONS
agg: yes [installing]
tkagg: yes [installing; run-time loading from Python Tcl/Tk]
macosx: yes [installing, darwin]

OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
error: command β€˜gcc’ failed with exit status 1

ERROR: Failed building wheel for matplotlib
Running setup.py clean for matplotlib
Failed to build matplotlib
Installing collected packages: matplotlib, pdpbox
Attempting uninstall: matplotlib
Found existing installation: matplotlib 3.3.4
Uninstalling matplotlib-3.3.4:
Successfully uninstalled matplotlib-3.3.4
Running setup.py install for matplotlib … error
ERROR: Command errored out with exit status 1:
command: /opt/anaconda3/bin/python -u -c β€˜import io, os, sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’; file=’"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’;f = getattr(tokenize, β€˜"’"β€˜open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"β€˜from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, β€˜"’"’\n’"’"’);f.close();exec(compile(code, file, β€˜"’"β€˜exec’"’"’))’ install --record /private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-record-249eq8ll/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.8/matplotlib
cwd: /private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/
Complete output (505 lines):
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
================================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
  matplotlib: yes [3.1.1]
      python: yes [3.8.8 (default, Apr 13 2021, 12:59:45)  [Clang 10.0.0 ]]
    platform: yes [darwin]

OPTIONAL SUBPACKAGES
 sample_data: yes [installing]
       tests: no  [skipping due to configuration]

OPTIONAL BACKEND EXTENSIONS
         agg: yes [installing]
       tkagg: yes [installing; run-time loading from Python Tcl/Tk]
      macosx: yes [installing, darwin]

OPTIONAL PACKAGE DATA
        dlls: no  [skipping due to configuration]
 gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/opt/anaconda3/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.macosx-10.9-x86_64-3.8/src/checkdep_freetype2.o -I/opt/anaconda3/include/freetype2
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1

ERROR: Command errored out with exit status 1: /opt/anaconda3/bin/python -u -c β€˜import io, os, sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’; file=’"’"’/private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-install-_a_ey__7/matplotlib_53c01178919f4685aa0b52f2a3252920/setup.py’"’"’;f = getattr(tokenize, β€˜"’"β€˜open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"β€˜from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, β€˜"’"’\n’"’"’);f.close();exec(compile(code, file, β€˜"’"β€˜exec’"’"’))’ install --record /private/var/folders/76/jw56v3017c7c5k0mkwn3s0fh0000gn/T/pip-record-249eq8ll/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.8/matplotlib Check the logs for full command output.

Have you set up your Mac for software development already?

To have GCC you generally have to install from Apple the Xcode Command Line toolkit.
According to here:

"Within the Xcode Command Line toolkit, Mac users gain access to numerous useful tools, utilities, and compilers, including make, GCC, clang, perl, svn, git, size, strip, strings, libtool, cpp, and many others. "

If you haven’t installed that prior, start there following the advice under β€˜How to install Xcode Command Line Tools?’ here and that might fix this.

YOU ARE A GENIUS!!! IT WORKED LIKE MAGIC!!! Thank you so much!! I spent so much time to troubleshoot this and finally it’s fixed. Thanks a ton :smiley:

1 Like