在Windows 10上安装Python 3.6的matplotlib和其他库失败

6

我最近买了一台新的笔记本电脑,想要安装我所有的Python库。但是有些库就是无法安装,比如matplotlib。

我的电脑信息:Windows 10系统,Python版本为3.6,根据pip显示已经安装了以下这些库。

colorama (0.3.7)
Django (1.8.17)
Mathics (1.0)
mpmath (0.19)
pip (9.0.1)
python-dateutil (2.6.0)
setuptools (32.3.0)
six (1.10.0)
sympy (1.0)
wheel (0.29.0)

"pip install matplotlib" 的结果:

Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Collecting matplotlib Using cached matplotlib-1.5.3.tar.gz Complete output from command python setup.py egg_info: Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored Error processing line 1 of c:\users\marvi\appdata\local\programs\python\python36\lib\site-packages\matplotlib-2.0.0rc2-py3.6-nspkg.pth:
Traceback (most recent call last): File "c:\users\marvi\appdata\local\programs\python\python36\lib\site.py", line 169, in addpackage exec(line) File "", line 1, in File "", line 557, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored ============================================================================ Edit setup.cfg to change the build options
BUILDING MATPLOTLIB matplotlib: yes [1.5.3] python: yes [3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]] platform: yes [win32]
REQUIRED DEPENDENCIES AND EXTENSIONS numpy: yes [not found. pip may install it below.] dateutil: yes [using dateutil version 2.6.0] pytz: yes [pytz was not found. pip will attempt to install it after matplotlib.] cycler: yes [cycler was not found. pip will attempt to install it after matplotlib.] tornado: yes [tornado was not found. It is required for the WebAgg backend. pip/easy_install may attempt to install it after matplotlib.] 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 freetype (ft2build.h) could not be found. You may need to install the development package.] png: no [The C/C++ header for png (png.h) could not be found. You may need to install the development package.] 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 / using unittest.mock] 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 / using unittest.mock]
OPTIONAL BACKEND EXTENSIONS macosx: no [Mac OS-X only] qt5agg: no [PyQt5 not found] qt4agg: no [PySide not found; PyQt4 not found] gtk3agg: no [Requires pygobject to be installed.] gtk3cairo: no [Requires cairocffi or pycairo to be installed.] gtkagg: no [Requires pygtk] tkagg: yes [installing; run-time loading from Python Tcl / Tk] wxagg: no [requires wxPython] gtk: no [Requires pygtk] agg: yes [installing] cairo: no [cairocffi or pycairo not found] windowing: yes [installing]
OPTIONAL LATEX DEPENDENCIES dvipng: no ghostscript: no latex: no pdftops: no
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 C:\Users\marvi\AppData\Local\Temp\pip-build-a0hjoody\matplotlib\

基本上,这是关于缓存文件的问题,还有一堆来自site.py的AttributeError错误以及一些关于没有freetype或png的内容。我尝试修复site.py,但仍然无法工作。我尝试了来自PyPi的.whl文件,但也不起作用。我尝试使用“pip install matplotlib --no-cache-dir”,结果相同。我尝试手动下载png和freetype,但找不到它们。我想要下载的所有其他库(NumPy,SciPy,pandas)都遇到了大致相同的问题。


1
所以,我尝试启动一个全新的Win 10操作系统,安装了Python 3.6,你是正确的。它缺少一些包...你可以在这里找到Freetype(https://sourceforge.net/projects/freetype/files/freetype2/2.7/),PNG(https://sourceforge.net/projects/libpng/files/libpng16/)也在这里。希望这能帮到你。 - andrepogg
1
尝试使用此freetype和此PNG。当您安装“exe”时,我认为您就可以了。 - andrepogg
我在 OS X 上使用 3.6 时遇到了类似的问题。 - cdarke
1
更新:在OS X上,从@andrepogg提供的链接安装freetype和PNG工作得很好。非常感谢。 - cdarke
如果有安慰的话,我已经在Windows 10上尝试了相同的程序,即使安装了freetype和png,结果仍然完全相同。 - cdarke
显示剩余7条评论
3个回答

2
1.5.1版本没有这个问题,请您检查一下:
pip install matplotlib==1.5.1 

1.5.1的输出相同:一堆AttributeError和找不到png或freetype。 - user5442649
我遇到了这个错误:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5rm3rvdv/matplotlib/ - Netmoon

2
如果您正在使用Python 3.6的Anaconda,则可以使用以下命令:
conda install -c conda-forge python=3.6.0
conda install matplotlib --channel conda-forge

要下载Anaconda,请访问https://www.continuum.io/downloads


然而我没有安装Anaconda,那么我该如何下载它呢? - user5442649
谢谢,但我现在不在电脑旁边,无法测试。 - user5442649
我决定使用Python 3.5.2,并下载了Anaconda,获得了许多库。谢谢! - user5442649

0

像你一样,我在这个问题上兜了很多圈!

如果你从PyPI安装,应该是没问题的。我使用的是matplotlib-2.0.0rc2-cp36-cp36m-win32.whl,但也有一个64位版本。

我使用 cmd.exe 以"管理员身份运行"进行安装,并将python目录添加到环境变量中:

pip3 install matplotlib-2.0.0rc2-cp36-cp36m-win32.whl

我收到了更多的错误信息:https://gist.github.com/ev3commander/3f1defb5cb440d7cddd4d2a6c89f2889 - user5442649
我觉得我需要删除所有与Python3.6相关的内容并下载Python3.5.4,因为在我的桌面上使用Python3.5.4时它可以正常工作... - user5442649
我以不同于你的方式安装了3.6,但我不知道这是否会有所不同。我进行了“自定义安装”,在“高级选项”中勾选了“为所有用户安装”。 这将3.6安装到“Program Files(x86)”而不是本地应用程序目录。 我曾经遇到过本地安装的其他问题。 - cdarke
你先执行了 pip3 install numpy 吗?从你的错误信息来看,这可能是问题所在。 - cdarke
我想补充一下我的报告,使用64位Python 3.6在Windows 10上,我成功地执行了“pip install numpy”,然后是“pip install matplotlib”...就这样。比在2.7下所需的步骤简单多了。 - Darren Ringer
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接