14.04中的动机:16.04 在生产使用中存在缺陷。14.04 是唯一稳定的版本。15.10 也存在缺陷。他们的 upstart/systemd 和 runit 很糟糕。
我跑masi@masi:~/BitTorrentSync/IPython$ sudo -H pip install matplotlib
Collecting matplotlib
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading matplotlib-1.5.1.tar.gz (54.0MB)
100% |████████████████████████████████| 54.0MB 26kB/s
Complete output from command python setup.py egg_info:
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.5.1]
python: yes [2.7.6 (default, Jun 22 2015, 17:58:13) [GCC
4.8.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.11.0]
dateutil: yes [using dateutil version 2.5.3]
pytz: yes [using pytz version 2016.4]
cycler: yes [cycler was not found. pip will attempt to
install it after matplotlib.]
tornado: yes [using tornado version 4.3]
pyparsing: yes [pyparsing was not found. It is required for
mathtext support. pip/easy_install may attempt to
install it after matplotlib.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' could not
be found.]
qhull: yes [pkg-config information for 'qhull' could not be
found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [nose 0.11.1 or later is required to run the
matplotlib test suite. Please install it with pip or
your preferred tool to run the test suite / mock is
required to run the matplotlib test suite. Please
install it with pip or your preferred tool to run
the test suite]
toolkits_tests: yes [nose 0.11.1 or later is required to run the
matplotlib test suite. Please install it with pip or
your preferred tool to run the test suite / mock is
required to run the matplotlib test suite. Please
install it with pip or your preferred tool to run
the test suite]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PyQt5 not found]
qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide not
found]
gtk3agg: yes [installing, version 3.8.10]
gtk3cairo: yes [installing, version 3.8.10]
gtkagg: no [The C/C++ header for gtk (gtk/gtk.h) could not
be found. You may need to install the development
package.]
tkagg: no [TKAgg requires Tkinter.]
wxagg: no [requires wxPython]
gtk: no [The C/C++ header for gtk (gtk/gtk.h) could not
be found. You may need to install the development
package.]
agg: yes [installing]
cairo: yes [installing, pycairo version 1.8.8]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: yes [version 9.10]
latex: no
pdftops: yes [version 0.24.5]
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
============================================================================
* The following required packages can not be built:
* freetype, png
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5VdgT2/matplotlib/
在哪里错误代码 1没有返回任何相应的线程。我在运行不带 的命令时得到了完全相同的错误sudo -H
。这是不完整的安装,尝试使用您获得的模块
ImportError: No module named matplotlib.pyplot
评论中的提案。我sudo apt-get install libfreetype6-dev libpng12-dev
成功运行。我成功运行sudo -H pip install matplotlib
。但是,现在运行 matplotlib 模块时出现警告
/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
如何在 Ubuntu 14.04 中安装 matplotlib?
答案1
Edwinksl 的评论和线最后一个警告是字体缓存警告。开始ipython
查找 Matplotlib 的缓存目录
In [2]: import matplotlib
In [3]: matplotlib.get_cachedir()
Out[3]: u'/home/masi/.cache/matplotlib'
就我而言,删除
rm /home/masi/.cache/matplotlib/fontList.cache
rm -r /home/masi/.cache/matplotlib/tex.cache/
现在,再次运行您的 matplotlib 测试代码。第一次运行时我又遇到了同样的错误。我第二次运行测试代码,问题解决了。Edwinksl 提出了为什么会出现这种行为
我猜想第一次迭代确实在构建缓存,因为它们不存在。在第二次迭代中,matplotlib 知道缓存存在,因此它不会再费心构建它们。