Skip to content

Cannot run tests with Python 3.x on MacOS 10.7 #745

Closed

Description

@astrofrog

If I try and run the matplotlib tests with Python 3.1 or 3.2 on MacOS X I get the following error (several times):

Traceback (most recent call last):
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/nose/failure.py", line 37, in runTest
    raise self.exc_class(self.exc_val).with_traceback(self.tb)
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/nose/loader.py", line 379, in loadTestsFromName
    module = resolve_name(addr.module)
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/nose/util.py", line 321, in resolve_name
    module = __import__('.'.join(parts_copy))
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/tests/test_text.py", line 4, in <module>
    from matplotlib.testing.decorators import image_comparison, knownfailureif
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/testing/decorators.py", line 9, in <module>
    from matplotlib import pyplot as plt
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/pyplot.py", line 24, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/figure.py", line 19, in <module>
    from .axes import Axes, SubplotBase, subplot_class_factory
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/axes.py", line 21, in <module>
    import matplotlib.dates as mdates
  File "/Users/Shared/Jenkins/Home/virtualenvs.nose/python3.1-numpy1.6.1/lib/python3.1/site-packages/matplotlib/dates.py", line 122, in <module>
    from dateutil.rrule import rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, \
  File "<string>", line None
SyntaxError: invalid syntax (rrule.py, line 55)

Activity

  1. mdboom commented on Mar 20, 2012

    @mdboom
    Member

    What directory are you running the test from? It looks like it's loading a non 2to3'd rrule.py.

  2. astrofrog commented on Mar 20, 2012

    @astrofrog
    ContributorAuthor

    I'm running the tests from the top level directory (same one the contains setup.py)

  3. pelson commented on Aug 19, 2012

    @pelson
    Member

    @astrofrog: Is this still happening?

  4. pwuertz commented on Aug 21, 2012

    @pwuertz
    Contributor

    I have the same problem with the current master with python3 on ubuntu..

  5. pelson commented on Aug 21, 2012

    @pelson
    Member

    Are you building matplotlib in place (i.e. python3 setup.py build_ext --inplace)? Is there a rrule.py file in your pwd?
    Would you mind providing the full traceback?

    We should try to get an answer to this (even if it is a case of a user issue) before 1.2.x.

  6. pwuertz commented on Aug 21, 2012

    @pwuertz
    Contributor

    I used python3 setup.py install --user and my working directory was the matplotlib source root.

    pwuertz@ares:~/Software/matplotlib$ python3 tests.py --tests=matplotlib.tests.test_backend_pdf
    E
    ======================================================================
    ERROR: Failure: SyntaxError (invalid syntax (rrule.py, line 55))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/nose/failure.py", line 37, in runTest
        raise self.exc_class(self.exc_val).with_traceback(self.tb)
      File "/usr/lib/python3/dist-packages/nose/loader.py", line 379, in loadTestsFromName
        module = resolve_name(addr.module)
      File "/usr/lib/python3/dist-packages/nose/util.py", line 321, in resolve_name
        module = __import__('.'.join(parts_copy))
      File "/home/pwuertz/.local/lib/python3.2/site-packages/matplotlib/tests/test_backend_pdf.py", line 4, in <module>
        from matplotlib import pyplot as plt
      File "/home/pwuertz/.local/lib/python3.2/site-packages/matplotlib/pyplot.py", line 26, in <module>
        from matplotlib.figure import Figure, figaspect
      File "/home/pwuertz/.local/lib/python3.2/site-packages/matplotlib/figure.py", line 19, in <module>
        from .axes import Axes, SubplotBase, subplot_class_factory
      File "/home/pwuertz/.local/lib/python3.2/site-packages/matplotlib/axes.py", line 21, in <module>
        import matplotlib.dates as mdates
      File "/home/pwuertz/.local/lib/python3.2/site-packages/matplotlib/dates.py", line 122, in <module>
        from dateutil.rrule import rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, \
      File "<string>", line None
    SyntaxError: invalid syntax (rrule.py, line 55)
    

    In the matplotlib root there is no rrule.py or dateutil directory.

  7. astrofrog commented on Aug 21, 2012

    @astrofrog
    ContributorAuthor

    @pelson - I'm still getting the exact same error with 62fe17f . As @mdboom pointed out, the rrule.py file is not being 2to3'd, which is what's causing the issue.

  8. mdboom commented on Aug 21, 2012

    @mdboom
    Member

    I've been not seeing this issue because I installed dateutil directly by hand. Obviously there's a problem when installing the matplotlib-shipped dateutil, and this should probably be addressed as part of #983.

  9. pwuertz commented on Aug 22, 2012

    @pwuertz
    Contributor

    The dateutil related error is gone, but the test modules are not found when running tests.py with python3..

    ======================================================================
    ERROR: Failure: AttributeError ('module' object has no attribute 'test_axes')
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/nose/failure.py", line 37, in runTest
        raise self.exc_class(self.exc_val).with_traceback(self.tb)
      File "/usr/lib/python3/dist-packages/nose/loader.py", line 379, in loadTestsFromName
        module = resolve_name(addr.module)
      File "/usr/lib/python3/dist-packages/nose/util.py", line 331, in resolve_name
        obj = getattr(obj, part)
    AttributeError: 'module' object has no attribute 'test_axes'
    
    ======================================================================
    ERROR: Failure: AttributeError ('module' object has no attribute 'test_backend_svg')
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/nose/failure.py", line 37, in runTest
        raise self.exc_class(self.exc_val).with_traceback(self.tb)
      File "/usr/lib/python3/dist-packages/nose/loader.py", line 379, in loadTestsFromName
        module = resolve_name(addr.module)
      File "/usr/lib/python3/dist-packages/nose/util.py", line 331, in resolve_name
        obj = getattr(obj, part)
    AttributeError: 'module' object has no attribute 'test_backend_svg'
    .
    .
    .
    
  10. mdboom commented on Aug 22, 2012

    @mdboom
    Member

    Hmm... I'm having trouble reproducing this. Are you sure you're installing matplotlib in your Python 3 environment first?

  11. pwuertz commented on Aug 22, 2012

    @pwuertz
    Contributor

    Embarrassingly, the tests are working just fine when my CWD isn't the matplotlib source folder. I installed matplotlib using "python3 setup.py install --user". I can call the tests.py from another folder or run python3, import matplotlib and run matplotlib.test(). This also works for the current master without your dateutil updates...

  12. mdboom commented on Aug 22, 2012

    @mdboom
    Member

    Ok -- I'll give the OP @astrofrog a chance to comment, but I'd like to merge this into the 1.2 release asap.

  13. astrofrog commented on Aug 22, 2012

    @astrofrog
    ContributorAuthor

    @mdboom - the code you've attached to #983 seems to do the trick, so once that's merged, this ticket can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions