首页 > 解决方案 > Matplotlib 无法导入,显示为类型错误

问题描述

我在osx机器上。Matplotlib 几天前工作正常,但今天当我想使用它时,它却无法导入。有一堆行,在底部它给了我一个类型错误,关于需要另一个变量的复制函数。我已经尝试重新安装它,但仍然不会让步。有什么想法吗?我对此还很陌生,所以我不知道发生了什么。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/__init__.py", line 138, in <module>
    from . import cbook, rcsetup
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/rcsetup.py", line 24, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/fontconfig_pattern.py", line 18, in <module>
    from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 5658, in <module>
    _reBracketExpr = Literal("[") + Optional("^").setResultsName("negate") + Group(OneOrMore(_charRange | _singleChar)).setResultsName("body") + "]"
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1480, in setResultsName
    return self._setResultsName(name, listAllMatches)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1483, in _setResultsName
    newself = self.copy()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1437, in copy
    cpy = copy.copy(self)
TypeError: copy() missing 2 required positional arguments: 'E' and 'X'

标签: pythonpython-3.xmacosmatplotlib

解决方案


感谢您的回复,原来 matplotlib 不喜欢我所在的目录,这很奇怪。只是改变我试图从工作中运行它的位置。


推荐阅读