pip install matplotlib: "no pkg-config"
Solution 1
sudo apt-get build-dep python-matplotlib
Solution 2
On Mac OS: I use which pkg-config
to check installation. If not, use brew to install and it works:
brew install pkg-config
Solution 3
Just install freetype fonts to get matplotlib.
sudo apt-get install freetype*
All the matplotlib files are installed to /usr/local/lib/python2.7/site-packages/. Even if you want to install using pip installer, you need to fix freetype font problem, which can be done as stated above.
Solution 4
I can't ask your specific questions, but my pip install matplotlib looked a lot like yours the other day. After five hours of slamming my head against the wall, this solution worked for me (from practicalcomputing.org
I got this set of commands to set up simlinks:
sudo mkdir -p /usr/local/include
sudo ln -s /usr/X11/include/freetype2/freetype /usr/local/include/freetype
sudo ln -s /usr/X11/include/ft2build.h /usr/local/include/ft2build.h
sudo ln -s /usr/X11/include/png.h /usr/local/include/png.h
sudo ln -s /usr/X11/include/pngconf.h /usr/local/include/pngconf.h
sudo ln -s /usr/X11/include/pnglibconf.h /usr/local/include/pnglibconf.h
sudo mkdir -p /usr/local/lib
sudo ln -s /usr/X11/lib/libfreetype.dylib /usr/local/lib/libfreetype.dylib
sudo ln -s /usr/X11/lib/libpng.dylib /usr/local/lib/libpng.dylib
It doesn't quite solve all your issues, but it solved my pkg-config issue (among others). Perhaps a similar link would help with QT.
Solution 5
Old question, but wanted to leave some possibly helpful crumbs.
I just dealt with a somewhat similar issue on Ubuntu 12.04 after trying to manually install an application that relied on a set of Python bindings that were manually installed within a virtualenv. The Python bindings were clearly installed in an appropriate place within my virtualenv, but the installer simply couldn't find them with pkg-config
.
So to answer the original questions:
- Where does pip install matplotlib get that basedirlist (3rd line of the output above)?
- Not sure, but I'm guessing this might be something matplotlib's setup.py hardcoded after it detected your OS/distribution/version.
- What must I do differently so that pip install matplotlib will find pkg-config?
- I'm fairly certain it's finding
pkg-config
just fine; it's just not detecting any useful information forfreetype2
andlibpng
.
- I'm fairly certain it's finding
- What must I do differently so that pip install matplotlib will find qt?
- This is all based on experience on Ubuntu 12.04.
- Installing
python-qt4
globally and creating a virtualenv with--system-site-packages
enabled should make matplotlib happy, even if it means littering your global environment with modules. But I haven't been able to get pip to do anything useful when trying to install PyQt4 or python-qt in a virtualenv. - Installing
libqt4-dev
should also alleviate any dependency issues when building anything relying on Qt4. - If that didn't work, and others' answers here didn't help, this may shed some light on why pip is unhappy:
-
man pkg-config
On most systems, pkg-config looks in /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig for these files. It will additionally look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment variable.
-
pkg-config
is looking for *.pc files; the fact that you found those dependencies installed somewhere doesn't meanpkg-config
will find any *.pc files in those directories. - As the man page indicates, if your packages are installed in funny places, you need to set
PKG_CONFIG_PATH
appropriately. - If you've perchance installed your packages into your virtualenv, then you need to make sure your virtualenv's activate/deactivate commands update PKG_CONFIG_PATH appropriately. The only way I got this to work was to modify the
bin/activate
script in my virtualenv.- You can pretty much copy the existing code that maintains an
_OLD_VIRTUAL_PATH
before updatingPATH
upon activation, and reverting back to_OLD_VIRTUAL_PATH
upon deactivation - Note that the existing code isn't perfect as of the time of this post, since if your
PKG_CONFIG_PATH
was blank to begin with, you need a bit more logic to make sure it gets cleared upon deactivation
- You can pretty much copy the existing code that maintains an
-
kjo
Updated on July 05, 2022Comments
-
kjo almost 2 years
When I run
pip install matplotlib
(within a virtualenv), the first lines of output are:Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local'] ============================================================================ BUILDING MATPLOTLIB matplotlib: 1.2.0 python: 2.7.3 (default, Dec 14 2012, 13:31:05) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] platform: darwin REQUIRED DEPENDENCIES numpy: 1.6.2 freetype2: found, but unknown version (no pkg-config) OPTIONAL BACKEND DEPENDENCIES libpng: found, but unknown version (no pkg-config) Tkinter: Tkinter: 81008, Tk: 8.5, Tcl: 8.5 Gtk+: no * Building for Gtk+ requires pygtk; you must be able * to "import gtk" in your build/install environment Mac OS X native: yes Qt: no Qt4: no PySide: no Cairo: no <snip>
Note
- the "no pkg-config", and
- the missing Qt library.
First, contrary to what the output above says,
pkg-config
is in fact installed and on thePATH
:% pkg-config --version 0.27.1 % which pkg-config /usr/local/bin/pkg-config
Second,
qt
is available in the same directory wherefreetype
andlibpng
were found:% ls -l /usr/local/opt/{freetype,libpng,qt} | cut -c43- /usr/local/opt/freetype -> ../Cellar/freetype/2.4.10/ /usr/local/opt/libpng -> ../Cellar/libpng/1.5.13/ /usr/local/opt/qt -> ../Cellar/qt/4.8.4/
My question has three parts:
- Where does
pip install matplotlib
get thatbasedirlist
(3rd line of the output above)? - What must I do differently so that
pip install matplotlib
will findpkg-config
? - What must I do differently so that
pip install matplotlib
will findqt
?