Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
astrofrog opened this Issue Mar 7, 2012 · 13 comments

Comments

Projects
None yet
4 participants
Contributor

astrofrog commented Mar 7, 2012

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

mdboom commented Mar 20, 2012

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

Contributor

astrofrog commented Mar 20, 2012

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

Member

pelson commented Aug 19, 2012

@astrofrog: Is this still happening?

Contributor

pwuertz commented Aug 21, 2012

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

Member

pelson commented Aug 21, 2012

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.

Contributor

pwuertz commented Aug 21, 2012

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.

Contributor

astrofrog commented Aug 21, 2012

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

Owner

mdboom commented Aug 21, 2012

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.

Contributor

pwuertz commented Aug 22, 2012

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

mdboom commented Aug 22, 2012

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

Contributor

pwuertz commented Aug 22, 2012

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

Owner

mdboom commented Aug 22, 2012

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

Contributor

astrofrog commented Aug 22, 2012

@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 Aug 22, 2012

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