Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
astrofrog opened this Issue · 13 comments

4 participants

@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)
@mdboom
Owner

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

@astrofrog

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

@pelson
Collaborator

@astrofrog: Is this still happening?

@pwuertz
Collaborator

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

@pelson
Collaborator

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.

@pwuertz
Collaborator

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.

@astrofrog

@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.

@mdboom
Owner

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.

@pwuertz
Collaborator

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'
.
.
.
@mdboom
Owner

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

@pwuertz
Collaborator

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...

@mdboom
Owner

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

@astrofrog

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

@mdboom mdboom closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.