问题
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 the PATH:
% pkg-config --version
0.27.1
% which pkg-config
/usr/local/bin/pkg-config
Second, qt is available in the same directory where freetype and libpng 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 matplotlibget thatbasedirlist(3rd line of the output above)?- What must I do differently so that
pip install matplotlibwill findpkg-config?- What must I do differently so that
pip install matplotlibwill findqt?
回答1:
sudo apt-get build-dep python-matplotlib
回答2:
For me (Mac OS), I use which pkg-config to check installation. If not, use brew to install and it works:
brew install pkg-config
回答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.
回答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.
回答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-configjust fine; it's just not detecting any useful information forfreetype2andlibpng.
- 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-qt4globally and creating a virtualenv with--system-site-packagesenabled 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-devshould 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-configOn 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-configis looking for *.pc files; the fact that you found those dependencies installed somewhere doesn't meanpkg-configwill 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_PATHappropriately. - 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/activatescript in my virtualenv.- You can pretty much copy the existing code that maintains an
_OLD_VIRTUAL_PATHbefore updatingPATHupon activation, and reverting back to_OLD_VIRTUAL_PATHupon deactivation - Note that the existing code isn't perfect as of the time of this post, since if your
PKG_CONFIG_PATHwas 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
回答6:
I had an almost identical error. I looked through the errors further down, and it seems like the problem was with freetype2.
I've had similarly frustrating issues with other packages that use freetype. For me, the compile error came from the following:
/usr/local/include/freetype2/freetype/*.h are the freetype files.
/usr/local/include is the search directory.
-Ifreetype/*.h is the flag passed to the compiler.
The problem is subtle, but I was able to get matplotlib to compile (which honestly, is approximately all I really care about) by copying /usr/local/include/freetype2/freetype -> /usr/local/include/freetype.
Hopefully this will help anyone who stumbles across this!
来源:https://stackoverflow.com/questions/13979916/pip-install-matplotlib-no-pkg-config