<p dir="auto">I used <code class="notranslate">setup.py install</code> today to install matplotlib in a venv. I got some rather hard to tackle tracebacks, as they were filled with exec's (meaning one can not see what the actual code is that fails).</p>
<p dir="auto">Ultimately this was caused by pyparsing calling <code class="notranslate">.filename</code> and <code class="notranslate">.lineno</code> on a tuple (it obviously expected some kind of different object). But the tuple did contain a filename and a lineno as the first two elements, and some other stuff (the tuple seemed to be coming from the backtrace package). This code was wrapped in something like <code class="notranslate">if PY3: ...</code></p>
<p dir="auto">As a random guess I decided to downgrade pyparsing from 2.1.2 to 2.1.1, and this solved the problem. Unfortunately, I am not able to reproduce this anymore, even when upgrading pyparsing to 2.1.2. Still I though a heads-up might be in place, if someone seems <code class="notranslate">AttributeError: 'tuple' object has no attribute 'filename'</code> with a traceback that is more of less useless.</p>
<p dir="auto">Every day we have a bunch of EC2 machines that start and install themselves.</p>
<p dir="auto">This morning, the <code class="notranslate">pip install matplotlib</code> returned this :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    Complete output from command /usr/bin/python3.4 -c &quot;import setuptools, tokenize;__file__='/tmp/pip-build-y7e201wb/matplotlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))&quot; install --record /tmp/pip-1h1al542-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
      File &quot;/tmp/pip-build-y7e201wb/matplotlib/setup.py&quot;, line 167, in &lt;module&gt;
        result = package.check()
      File &quot;/tmp/pip-build-y7e201wb/matplotlib/setupext.py&quot;, line 1246, in check
        import pyparsing
      File &quot;/usr/local/lib/python3.4/site-packages/pyparsing.py&quot;, line 3478, in &lt;module&gt;
        _escapedPunc = Word( _bslash, r&quot;\[]-*.$+^?()~ &quot;, exact=2 ).setParseAction(lambda s,l,t:t[0][1])
      File &quot;/usr/local/lib/python3.4/site-packages/pyparsing.py&quot;, line 948, in setParseAction
        self.parseAction = list(map(_trim_arity, list(fns)))
      File &quot;/usr/local/lib/python3.4/site-packages/pyparsing.py&quot;, line 808, in _trim_arity
        this_line = extract_stack()[-1]
      File &quot;/usr/local/lib/python3.4/site-packages/pyparsing.py&quot;, line 793, in extract_stack
        return [(frame_summary.filename, frame_summary.lineno)]
    AttributeError: 'tuple' object has no attribute 'filename'
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.5.1]
                    python: yes [3.4.3 (default, Apr  1 2015, 18:10:40)  [GCC
                            4.8.2 20140120 (Red Hat 4.8.2-16)]]
                  platform: yes [linux]

    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 [using cycler version 0.10.0]
                   tornado: yes [using tornado version 4.3]
"><pre class="notranslate"><code class="notranslate">    Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-y7e201wb/matplotlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1h1al542-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "&lt;string&gt;", line 1, in &lt;module&gt;
      File "/tmp/pip-build-y7e201wb/matplotlib/setup.py", line 167, in &lt;module&gt;
        result = package.check()
      File "/tmp/pip-build-y7e201wb/matplotlib/setupext.py", line 1246, in check
        import pyparsing
      File "/usr/local/lib/python3.4/site-packages/pyparsing.py", line 3478, in &lt;module&gt;
        _escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1])
      File "/usr/local/lib/python3.4/site-packages/pyparsing.py", line 948, in setParseAction
        self.parseAction = list(map(_trim_arity, list(fns)))
      File "/usr/local/lib/python3.4/site-packages/pyparsing.py", line 808, in _trim_arity
        this_line = extract_stack()[-1]
      File "/usr/local/lib/python3.4/site-packages/pyparsing.py", line 793, in extract_stack
        return [(frame_summary.filename, frame_summary.lineno)]
    AttributeError: 'tuple' object has no attribute 'filename'
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.5.1]
                    python: yes [3.4.3 (default, Apr  1 2015, 18:10:40)  [GCC
                            4.8.2 20140120 (Red Hat 4.8.2-16)]]
                  platform: yes [linux]

    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 [using cycler version 0.10.0]
                   tornado: yes [using tornado version 4.3]

</code></pre></div>
<p dir="auto">What happens ?</p>
<p dir="auto">Our stack</p>
<ul dir="auto">
<li>python 3.4, amazon linux</li>
</ul>