Solved Error install pip matplotlib

I previously had matplotlib installed on my system but upon an update of packages it was somehow removed. Now upon trying to reinstall it I get the following error below - already tried multiple times for a couple of hours to solve it , can't seem to make progress.

Bash:
pip-3.9 install --user matplotlib
Collecting matplotlib
  Using cached matplotlib-3.9.0.tar.gz (36.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
 
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [181 lines of output]
      + meson setup /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135 /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/.mesonpy-biatwyn2 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/.mesonpy-biatwyn2/meson-python-native-file.ini
      The Meson build system
      Version: 1.4.1
      Source dir: /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135
      Build dir: /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/.mesonpy-biatwyn2
      Build type: native build
      Program python3 found: YES
      Project name: matplotlib
      Project version: 3.9.0
      C compiler for the host machine: cc (clang 16.0.6 "FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)")
      C linker for the host machine: cc ld.lld 16.0.6
      C++ compiler for the host machine: c++ (clang 16.0.6 "FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)")
      C++ linker for the host machine: c++ ld.lld 16.0.6
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python found: YES (/usr/local/bin/python3.9)
      Found pkg-config: YES (/usr/local/bin/pkg-config) 2.2.0
      Run-time dependency python found: YES 3.9
      pybind11-config found: YES (/tmp/pip-build-env-ihi_ixj8/overlay/bin/pybind11-config) 2.12.0
      Run-time dependency pybind11 found: YES 2.12.0
      Downloading freetype-2.6.1 source from https://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-2.6.1.tar.gz
      <urlopen error _ssl.c:1117: The handshake operation timed out>
      WARNING: failed to download with error: could not get https://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-2.6.1.tar.gz is the internet available?. Trying after a delay...
      
      Executing subproject freetype-2.6.1
      
      freetype-2.6.1| Project name: freetype2
      freetype-2.6.1| Project version: 2.6.1
      freetype-2.6.1| C compiler for the host machine: cc (clang 16.0.6 "FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)")
      freetype-2.6.1| C linker for the host machine: cc ld.lld 16.0.6
      freetype-2.6.1| Configuring ftconfig.h using configuration
      freetype-2.6.1| ../subprojects/freetype-2.6.1/meson.build:174: WARNING: Got an empty configuration_data() object and found no substitutions in the input file 'ftconfig.h'. If you want to copy a file to the build dir, use the 'copy:' keyword argument added in 0.47.0
      freetype-2.6.1| Configuring ftoption.h using configuration
      freetype-2.6.1| Build targets in project: 3
      freetype-2.6.1| Subproject freetype-2.6.1 finished.
      
      Downloading qhull source from https://github.com/qhull/qhull/archive/v8.0.2/qhull-8.0.2.tar.gz
      
      Executing subproject qhull
      
      qhull| Project name: qhull
      qhull| Project version: 8.0.2
      qhull| C compiler for the host machine: cc (clang 16.0.6 "FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)")
      qhull| C linker for the host machine: cc ld.lld 16.0.6
      qhull| Build targets in project: 4
      qhull| Subproject qhull finished.
      
      Run-time dependency dl found: YES
      Configuring _version.py using configuration
      Program /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/tools/generate_matplotlibrc.py found: YES (/tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/tools/generate_matplotlibrc.py)
      Build targets in project: 14
      
      matplotlib 3.9.0
      
        Subprojects
          freetype-2.6.1: YES 1 warnings
          qhull         : YES
      
        User defined options
          Native files  : /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/.mesonpy-biatwyn2/meson-python-native-file.ini
          buildtype     : release
          b_ndebug      : if-release
          b_vscrt       : md
      
      Found ninja-1.11.1 at /usr/local/bin/ninja
      + /usr/local/bin/ninja
      [1/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_trans_affine.cpp.o
      [2/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_bezier_arc.cpp.o
      [3/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_image_filters.cpp.o
      [4/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_curves.cpp.o
      ../extern/agg24-svn/src/agg_curves.cpp:24:18: warning: unused variable 'curve_distance_epsilon' [-Wunused-const-variable]
          const double curve_distance_epsilon                  = 1e-30;
                       ^
      1 warning generated.
      [5/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_vpgen_segmentator.cpp.o
      [6/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftbdf.c.o
      [7/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftbbox.c.o
      [8/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_vcgen_dash.cpp.o
      [9/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_vcgen_contour.cpp.o
      [10/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftcid.c.o
      [11/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftfntfmt.c.o
      [12/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftfstype.c.o
      [13/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftgasp.c.o
      [14/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftbitmap.c.o
      [15/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftinit.c.o
      [16/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftglyph.c.o
      [17/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftlcdfil.c.o
      [18/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftgxval.c.o
      [19/101] Compiling C++ object extern/agg24-svn/libagg.a.p/src_agg_vcgen_stroke.cpp.o
      [20/101] Linking static target extern/agg24-svn/libagg.a
      [21/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftmm.c.o
      [22/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftotval.c.o
      [23/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftpfr.c.o
      [24/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftpatent.c.o
      [25/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftsystem.c.o
      [26/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftsynth.c.o
      [27/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_fttype1.c.o
      [28/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftwinfnt.c.o
      [29/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_bzip2_ftbzip2.c.o
      [30/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftstroke.c.o
      [31/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_cid_type1cid.c.o
      [32/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_bdf_bdf.c.o
      [33/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_lzw_ftlzw.c.o
      [34/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_cache_ftcache.c.o
      [35/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_gzip_ftgzip.c.o
      [36/101] Compiling C++ object extern/ttconv/libttconv.a.p/ttutil.cpp.o
      [37/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_autofit_autofit.c.o
      [38/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_pcf_pcf.c.o
      [39/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftbase.c.o
      [40/101] Compiling C++ object extern/ttconv/libttconv.a.p/pprdrv_tt.cpp.o
      [41/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_pfr_pfr.c.o
      [42/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_psnames_psnames.c.o
      [43/101] Compiling C++ object extern/ttconv/libttconv.a.p/pprdrv_tt2.cpp.o
      [44/101] Linking static target extern/ttconv/libttconv.a
      [45/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_smooth_smooth.c.o
      [46/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_psaux_psaux.c.o
      [47/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_type42_type42.c.o
      [48/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_base_ftdebug.c.o
      [49/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_raster_raster.c.o
      [50/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_winfonts_winfnt.c.o
      [51/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_pshinter_pshinter.c.o
      [52/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_geom_r.c.o
      ../subprojects/qhull-8.0.2/src/libqhull_r/geom_r.c:623:24: warning: variable 'flip' set but not used [-Wunused-but-set-variable]
        int i, j, k, pivoti, flip=0;
                             ^
      1 warning generated.
      [53/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_cff_cff.c.o
      [54/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_mem_r.c.o
      [55/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_type1_type1.c.o
      [56/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_geom2_r.c.o
      [57/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_libqhull_r.c.o
      [58/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_random_r.c.o
      [59/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_global_r.c.o
      [60/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_usermem_r.c.o
      [61/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_poly_r.c.o
      [62/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_qset_r.c.o
      [63/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_userprintf_r.c.o
      [64/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_userprintf_rbox_r.c.o
      [65/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_sfnt_sfnt.c.o
      [66/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_user_r.c.o
      [67/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_rboxlib_r.c.o
      [68/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_stat_r.c.o
      [69/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_poly2_r.c.o
      ../subprojects/qhull-8.0.2/src/libqhull_r/poly2_r.c:103:37: warning: variable 'notgood' set but not used [-Wunused-but-set-variable]
        int numpart= 0, facet_i, facet_n, notgood= 0, notverified= 0;
                                          ^
      1 warning generated.
      [70/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_io_r.c.o
      [71/101] Compiling C object subprojects/qhull-8.0.2/libqhull_r.a.p/src_libqhull_r_merge_r.c.o
      ../subprojects/qhull-8.0.2/src/libqhull_r/merge_r.c:2907:17: warning: variable 'total' set but not used [-Wunused-but-set-variable]
        int cycles=0, total=0, facets, nummerge, numdegen= 0;
                      ^
      1 warning generated.
      [72/101] Linking static target subprojects/qhull-8.0.2/libqhull_r.a
      [73/101] Compiling C object subprojects/freetype-2.6.1/libfreetype.a.p/src_truetype_truetype.c.o
      [74/101] Linking static target subprojects/freetype-2.6.1/libfreetype.a
      [75/101] Compiling C++ object src/_backend_agg.cpython-39.so.p/py_converters.cpp.o
      [76/101] Compiling C++ object src/_backend_agg.cpython-39.so.p/_backend_agg.cpp.o
      [77/101] Compiling C++ object src/ft2font.cpython-39.so.p/ft2font_wrapper.cpp.o
      [78/101] Compiling C++ object src/ft2font.cpython-39.so.p/py_converters.cpp.o
      [79/101] Compiling C++ object src/ft2font.cpython-39.so.p/ft2font.cpp.o
      [80/101] Compiling C++ object src/_path.cpython-39.so.p/py_converters.cpp.o
      [81/101] Compiling C++ object src/_backend_agg.cpython-39.so.p/_backend_agg_wrapper.cpp.o
      [82/101] Compiling C++ object src/_c_internal_utils.cpython-39.so.p/_c_internal_utils.cpp.o
      [83/101] Compiling C++ object src/_image.cpython-39.so.p/py_converters_11.cpp.o
      [84/101] Linking target src/_c_internal_utils.cpython-39.so
      [85/101] Compiling C++ object src/_path.cpython-39.so.p/py_converters_11.cpp.o
      [86/101] Generating lib/matplotlib/mpl-data/matplotlibrc with a custom command
      FAILED: lib/matplotlib/mpl-data/matplotlibrc
      /tmp/pip-install-rcou73lf/matplotlib_5ac74687a538428296422d9a7844a135/tools/generate_matplotlibrc.py ../lib/matplotlib/mpl-data/matplotlibrc lib/matplotlib/mpl-data/matplotlibrc auto
      env: python3: No such file or directory
      [87/101] Compiling C++ object src/_qhull.cpython-39.so.p/_qhull_wrapper.cpp.o
      [88/101] Linking target src/_backend_agg.cpython-39.so
      [89/101] Compiling C++ object src/_tkagg.cpython-39.so.p/_tkagg.cpp.o
      [90/101] Compiling C++ object src/_image.cpython-39.so.p/_image_wrapper.cpp.o
      [91/101] Compiling C++ object src/_tri.cpython-39.so.p/tri__tri.cpp.o
      [92/101] Compiling C++ object src/_path.cpython-39.so.p/_path_wrapper.cpp.o
      [93/101] Compiling C++ object src/_ttconv.cpython-39.so.p/_ttconv.cpp.o
      [94/101] Compiling C++ object src/_tri.cpython-39.so.p/tri__tri_wrapper.cpp.o
      [95/101] Linking target src/ft2font.cpython-39.so
      ninja: build stopped: subcommand failed.
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
 
FWIW this builds successfully and I am able to import matplotlib in a python interpreter

pip-3.9 install --user matplotlib==3.8.4

But it doesn't work for the default version of matplotlib which is currently 3.9.0 according to https://pypi.org/project/matplotlib/#history

The Python default changing from 3.9 to 3.11?
I see - but my system is still running 3.9 and the above pip install works just fine. Do I need to do something?
 
Do I need to do something?
You're probably using quarterly packages, in that case, no. This change recently happened in 'latest', but you might run into this when the new quarterly branch is made.
 
You're probably using quarterly packages, in that case, no. This change recently happened in 'latest', but you might run into this when the new quarterly branch is made.
Thanks. Yes, using quarterly. Still wondering what's causing this matplotlib installation issue ?
 
Code:
     env: python3: No such file or directory
It's looking for a python3 executable, which doesn't exist on FreeBSD. There are only executables with the full version in their name, python3.9 for example.

You can probably circumvent this issue by creating a symlink in your ~/bin directory.

Code:
mkdir ~/bin
ln -s /usr/local/bin/python3.9 ~/bin/python3

The ~/bin directory should be part of the default PATH.
 
Code:
     env: python3: No such file or directory
It's looking for a python3 executable, which doesn't exist on FreeBSD. There are only executables with the full version in their name, python3.9 for example.

You can probably circumvent this issue by creating a symlink in your ~/bin directory.

Code:
mkdir ~/bin
ln -s /usr/local/bin/python3.9 ~/bin/python3

The ~/bin directory should be part of the default PATH.
Perfect - this was the solution. Thank you so much!

Checks out in the interpreter.
Python:
>>> import matplotlib
>>> matplotlib.__version__
'3.9.0'
 
Hi Tracker,
just for the record, matplotlib is also available as a pre-build package py39-matplotlib-3.8.0_1. It is for Python3.9, too but slightly behind the latest version 3.9.0 you have got using pip.
 
Back
Top